Dual rule
For the first 300 years that Portuguese lived in Macau, they did so as tenants, while professing obedience to the Ming and Qing emperors. As Wu Zhiliang, director of the Macau Foundation, says, the Portuguese ran Macau under a "dual rule" situation. "In fact, people now talk of the Portuguese invading' China, but before the late Qing dynasty, this was not at all the situation," he says. It was only in 1887 that Macau formally, by treaty, came under Portuguese sovereignty, with the "Sino-Portuguese Treaty of Commerce and Friendship," which is more commonly called the "Sino-Portuguese Treaty of Peking."
This important document was originally kept in the Imperial Zongli Yamen (which handled foreign affairs). After the establishment of the Republic of China, it was transferred to the Foreign Ministry. Just like the Nanking Treaty which decided the fate of Hong Kong, this Sino-Portuguese treaty has been kept in the ministry all these years.
Portuguese refusal to continue the lease arrangement with the Qing dynasty was connected with the Opium War and the British seizure of Hong Kong in 1842. At that time the Portuguese in Macau felt threatened by Britain, and in 1843 submitted a list of demands to the Chinese: halting of rent payments for Macau, expansion of Macau's boundaries, elimination of the need for Portuguese to apply for licenses for construction buildings, reduction of taxes on Portuguese goods, and access to five new ports for trading. Eventually the Qing agreed to the demand for access to the five ports, but refused to terminate the lease payments. So the Portuguese simply refused to pay the rent, and moreover began to expand their area of control, even "sub-letting" part of Macau to the British.
It was only with the signing of the Sino-Portuguese Treaty of Peking in 1887 that the Qing court formally accepted permanent Portuguese control of Macau. In return, the Portuguese promised not to cede the colony to any third country.
Unfortunately, thereafter on several occasions the Portuguese continued to expand their area of control in Macau. The exhibits at the National Palace Museum include vital documents from that period, including the Chinese, Portuguese, and French versions of a series of unequal treaties as well as maps showing evidence of Portuguese transgressions.

After its establishment, the ROC moved quickly to open negotiations with Portugal and other powers to terminate the unequal treaties. The photo shows a Sino-Portuguese agreement of 1936 which says: "The government of the Republic of Portugal agrees to turn over to the government of the Republic of China all administration and control of the Macau area as well as all government-owned property and government functions there." (courtesy of the Academia Historica)