Heavy fighting raged in Qui Nhơn for control of the fortress until it was captured in 1799. Pigneau died there of dysentery on 9 October in the same year, after serving his final years as an advisor and "de facto" foreign minister to Nguyễn Ánh. He was buried at Saigon with full military honours. Nguyễn Ánh's funeral oration described him as "the most illustrious foreigner ever to appear at the court of Cochinchina." He was buried on 16 December 1799 in the presence of the crown prince, all mandarins of the court, the royal bodyguard of 12,000 men and 40,000 mourners.