During the Tang Dynasty a steady stream of Arab and Persian traders arrived in China through the Silk Road and the overseas route through the port of Quanzhou. The Muslim mosques were located in the foreign quarter on the south bank of the Canton River. Not all of the immigrants were Muslims, but many of those who stayed formed the basis of the Chinese Muslim population and the Hui ethnic group. In 758 a large Muslim settlement in Guangzhou erupted in unrest and fled. The same year, Arab and Persian pirates who may have been based in a port on the island of Hainan, caused some of the trade to divert to Northern Vietnam and the Chaozhou area, near the Fujian border. The Muslim community in Canton had constructed a large mosque (Huaisheng Mosque), which was destroyed by fire in 1314, and reconstructed in 1349-51 (however, only the ruins of a tower remain from the first building).
The Arab and Persian immigrants introduced polo, their cuisine, musical instruments, and their knowledge of Islamic medicine to China. In 923, the Chinese botanist Li Hsün's Medical Matters from the Countries beyond the Sea described 121 medicinal drugs imported from the Western Regions, generally referring to Central Asia, the Indian subcontinent, and the Middle East. He introduced fifteen new entries to the Chinese lexicon adopted from the Western Regions. The famous Persian physician Muhammad ibn Zakarīya Rāzi (known as Rhazes in Europe) had a Chinese student who impressed him with his ability to listen to his lectures and take down notes very quickly using a form of Chinese shorthand known as 'grass-writing'. This may have inspired the naming system used by Razi to classify drugs in Arabic pharmacology. Some Arab pharmacologists in the 9th century had also learnt Chinese herbal medicine.