This paper explores the history of the Huihui of Changzhi, Shanxi, particularly the Ma and Cheng surnames, in Ming-Qing, illustrating the links between lineage development, the lijia corvee system and mosque construction. The author argues that the development of lineages among the Huihui was shaped by the lijia registration and tax and corvee systems of the Ming. Numerous independent lineages sharing the same surname developed as service and tax payment units. At one level the construction of mosques was a product of lineage development, with mosques remaining continuously under lineage control and serving as a main location for lineage members' activities. At the same time, the coexistence, cooperation and competition between lineages in the mosques encouraged the further institutionalization of lineages, and deepened the ties between lineages sharing a common belief system. In the Qing, lineages continued to be organized around fulfillment of lijia obligations, and thereby maintained and even strengthened the ties between their own lineage members. As the Cheng and Ma gradually lost effective control over mosque activities, the mosque gradually transformed from an organization handling lineage matters to one dealing with local affairs more broadly, and this in turn led to changes in the inter-relationships among the various Huihui lineages.