Macau is a Special Administrative Region (SAR) of the People's Republic of China. Macau became a colony of the Portuguese empire in 1557. It was lent to Portugal as a trading post but remained under Chinese authority and sovereignty. Self-administration was next achieved in the 1840s. When the Qing dynasty and Portugal signed the Sino-Portuguese Treaty of Peking in 1887, the treaty terms made Macau a Portuguese territory again until 1999, when it was handed over to China. Macau was the last extant European territory in continental (on-shore) Asia.
The human history of Macau stretches back up to 6,000 years, and includes many different and diverse civilisations and periods of existence. Evidence of human and culture dating back 4,000 to 6,000 years has been discovered on the Macau Peninsula and dating back 5,000 years on Coloane Island.
During the Qin Dynasty (221–206 BC), the region came under the jurisdiction of Panyu County, Nanhai Prefecture of the province of Guangdong. It was administratively part of Dongguan Prefecture in the Jin Dynasty (265–420 AD), and alternated under the control of Nanhai and Dongguan in later dynasties. In 1152, during the Song dynasty (960–1279 AD), it was under the jurisdiction of the new Xiangshan County.