 Portugal's involvement in the region was formally recognised by the Qing in 1749.The Portuguese governor João Maria Ferreira do Amaral, emboldened by the First Opium War and the Treaty of Nanking, attempted to annex the territory, expelling Qing authorities in 1846, but was assassinated.After the Second Opium War, the Portuguese government, along with a British representative, signed the 1887 Sino-Portuguese Treaty of Peking that gave Portugal perpetual colonial rights to Macau on the condition that Portugal would cooperate in efforts to end the smuggling of opium.