The mountain regions of western Tonkin were inhabited by tribesmen who did not acknowledge the writ of the Vietnamese government, and these montagnards resented the arrival of the Black Flag Army on Vietnamese soil. Fearing that Liu might eventually pose a threat to their own ascendancy in the area, they declared their intention of attacking the intruders. Liu struck first, however, and defeated a far stronger army of montagnards in a surprise attack. The short conflict enabled Liu to come to an early arrangement with the Vietnamese authorities, who had observed the performance of the Black Flag Army with great interest. The Vietnamese government, reasoning that it would be difficult to dislodge Liu from its territory and that he might also be a useful ally against the refractory montagnards, co-opted Liu into its service in 1869 and gave him military rank in the Vietnamese army. Provided that he continued to act in accordance with his technical status as a Vietnamese military governor, the Vietnamese authorities promised not to trouble the Black Flag leader.