The colony's name is derived from the Ma Kwok temple, built there in the 14th cent. Macao was the oldest permanent European settlement in East Asia. It was a parched and desolate spot when the Portuguese established a trading post there in 1557. For nearly 300 years the Portuguese paid China an annual tribute for the use of the peninsula, but in 1849 Portugal proclaimed it a free port; this was confirmed by China in the Protocol of Lisbon in 1887. With the gradual silting up of its harbor and the rise (19th cent.) of Hong Kong, Macao lost its preeminent position and became identified to a large extent with smuggling and gambling interests.
After 1949 the population was swelled by an influx of Chinese refugees from the mainland. In the winter of 1966–67, Communist-organized riots shook the province, resulting in a capitulation by the Portuguese to Chinese demands to bar entry to refugees and prohibit anti-Communist activities. In 1974, Macao was established as a Chinese territory under Portuguese administration; the Chinese refused to accept the return of the territory at the time. A real-estate boom in the early 1990s had largely waned by the end of the decade, but with end of the monopoly in its gambling industry the territory began a new period of real-estate and economic growth. Under the terms of a 1987 agreement, Macao became a special administrative region under Chinese sovereignty in Dec., 1999. Macao has been promised 50 years of noninterference in its economic and social systems.