Before the tenth century, there was no Islam in Xinjiang. The Karahan dynasty, which was active in this area at that time, absolutely prohibited the introduction of Islam. Bogra Khan, the third generation of the Karahan dynasty, had a good friend, Abu nasr Samani, the prince of the Persian Saman dynasty (who later became his religious teacher), who often passed on some Islamic teachings to him, and he began to know and understand Islam. After Bogra Khan succeeded to the throne, he became the king of the khanate. Samani said to King Khan, "Give me a place as big as cowhide and let me build a mosque." King Khan agreed. So Prince Samani cut a piece of cowhide into silk, circled the land and built the first mosque in Xinjiang.
Since then, Islam has spread throughout Xinjiang from here.