The Imperial army numbered 13,000 men invaded Cambodia in 1809 and 1813 in order to protect the faction of the king Ang Chan II of Cambodia, established the Viceroy of Cambodia, with Trương Tấn Bửu held the title Viceroy. In 1827 they were mobilized for the intervention in the Vientiane Kingdom in Laos. In 1833 when the Chakri Siamese army invaded Cambodia, much of the Nguyen army stationing in Cambodia had to withdraw back to suppress the Lê Văn Khôi revolt and Nông Văn Vân's Rebellion. In 1834 emperor Minh Mang launched the annexation of Cambodia after the Siamese army had been forced to retreat. Minh Mang died in early 1841. Siam launched the second invasion of Cambodia. Although the Nguyen army successfully retook Phnom Penh in 1845, the emperor of Vietnam Thieu Tri sought to make peace with Siam. A peace treaty between Siam and Vietnam was signed in March 1847, which resulted in the independence of Cambodia in 1848. Between 1802 to 1862, the Nguyen army also had faced 405 internal rebellions and revolts from small to large scales, mostly were the Lê Loyalists, ethnic minorities, and princely. The Imperial army gradually lost to France and Spain during the Cochinchina Campaign (1858–1862). After the Treaty of Saigon (1874), Vietnamese military units in Tonkin were eliminated and replaced by police forces.