Macau was formerly a colony of the Portuguese Empire, after Ming China leased the territory as a trading post in 1557. Portugal governed the area under Chinese authority and sovereignty until 1887, when it was given perpetual occupation rights for Macau. The colony remained under Portuguese control until 1999, when it was returned to China. As a special administrative region, Macau's system of government is separate from that of mainland China.
The first known written record of the name "Macau", rendered as "Ya/A Ma Gang" ("亞/阿-媽/馬-港"), is in a letter dated 20 November 1555. The local inhabitants believed that the sea goddess Mazu (alternatively called A-Ma) had blessed and protected the harbour and called the waters around A-Ma Temple using her name. When Portuguese explorers first arrived in the area and asked for the place name, the locals thought they were asking about the temple and told them it was "Ma Kok" (媽閣). The earliest Portuguese spelling for this was Amaquão. Multiple variations were used until Amacão / Amacao and Macão / Macao became common during the 17th century, gradually standardising as Macao, and Macau today.
Macau Peninsula had many names in Chinese, including Jing'ao (井澳/鏡澳), Haojing (濠鏡), and Haojing'ao (濠鏡澳). The islands Taipa, Coloane, and Hengqin were collectively called Shizimen (十字門). These names would later become Aomen (澳門), Oumún in Cantonese and translating as "bay gate" or "port gate", to refer to the whole territory.