The Margary Affair (Chinese: 马嘉理事件; pinyin: Mǎjiālǐ Shìjiàn or 滇案; Diān àn) was a crisis in Sino-British relations, which followed the murder of British official Augustus Raymond Margary in 1875.
As part of efforts to explore overland trade routes between British India and China's provinces, junior British diplomat Augustus Raymond Margary was sent from Shanghai through southwest China to Bhamo in Upper Burma, where he was supposed to meet Colonel Horace Browne. It took Margary six months to make the 1,800-mile (2,900 km) journey through the provinces of Sichuan, Guizhou and Yunnan and he met Brown in Bhamo in late 1874. On the journey back to Shanghai, Margary heard rumors that the return route was not safe and changed the route to Tengyue. However, he did not notify local officials of their arrivals and confronted native people. In a following conflict on 21 February 1875, he and his four Chinese personal staff were killed.
The incident created a diplomatic crisis and gave British authorities an excuse to put pressure on the Qing government. The crisis was only resolved in 1876 when Thomas Wade and Li Hongzhang signed the Chefoo Convention, which covered a number of items unrelated to the incident.