The history of Macau is traced back to the Qin Dynasty (221–206 BC), when the region now called Macau came under the jurisdiction of Panyu county, in Nanhai prefecture (present day Guangdong). The first recorded inhabitants of the area were people seeking refuge in Macau from invading Mongols during the Southern Song Dynasty. Under the Ming Dynasty (1368–1644 AD), fishermen migrated to Macau from Guangdong and Fujian provinces.
Macau did not develop as a major settlement until the Portuguese arrived in the 16th century. In 1535, Portuguese traders obtained the rights to anchor ships in Macau's harbours and to carry out trading activities, though not the right to stay onshore. Around 1552–1553, they obtained temporary permission to erect storage sheds onshore, in order to dry out goods drenched by sea water; they soon built rudimentary stone houses around the area now called Nam Van. In 1557, the Portuguese established a permanent settlement in Macau, paying an annual rent of 500 taels ( 20 kilos / 44 pounds ) of silver. The Portuguese continued to pay an annual tribute up to 1863 in order to stay in Macau.
By 1564 Portugal commanded western trade with India, Japan, and China. But their pride was shocked by the indifference with which the Chinese treated them. (The senate of Macau once complained to the viceroy of Goa of the contempt with which the Chinese authorities treated them, confessing however that “it was owing more to the Portuguese themselves than to the Chinese”.) In 1631 the Chinese restricted Portuguese commerce in China to the port of Macau.
During the 17th century some 5,000 slaves lived in Macau, in addition to 2,000 Portuguese and 20,000 Chinese.
As more Portuguese settled in Macau to engage in trade, they made demands for self-administration; but this was not achieved until the 1840s. In 1576, Pope Gregory XIII established the Roman Catholic Diocese of Macau. In 1583, the Portuguese in Macau were permitted to