Wenfei Wang, Shangyi Zhou, and Cindy Fan stated that according to historical records the first Hui arrived in Madian during the reign of the Kangxi Emperor of the Qing Dynasty. Turmoil in northwestern China during the Qing Dynasty caused many Hui to move eastward. A population of Hui, mostly horse and sheep traders, settled in Madian due to its access to horse and sheep trading routes. Therefore, a large trading market in horses and sheep was established there. Wenfei Wang, Shangyi Zhou, and Cindy Fan argued that the name "Madian" may have originated from the horse trading that occurred there and argued that this "may also be related to" the prevalence of the Ma family name in Madian. Kangxi built the Madian Mosque in 1662. Wenfei Wang, Shangyi Zhou, and Cindy Fan had interviewed an administrator of the mosque, who stated that the mosque "probably" opened due to a pre-existing Hui population.