The Khalkha rulers, defeated, fled to Hohhot and sought Qing assistance. Meanwhile, the Qing had secured a peace treaty with the Cossacks on their northern border, who had previously been inclined to support Galdan. The Treaty of Nerchinsk prevented an alliance between Galdan and the Russians, leaving the Qing free to attack their Mongol rivals. Fearing a united Mongol state ruled by the hostile Dzungars, the Qing now turned their powerful war machine on the Oirats. The Dzungars had conquered and subjugated the Uyghurs during the Dzungar conquest of Altishahr after being invited by the Afaqi Khoja to invade the Chingisid Chagatai ruled Yarkent Khanate. Heavy taxes were imposed upon the Uyghurs by the Dzungars, provoking resentment. This led to uprisings and Uyghur rebels from Turfan and Kumul who were rebelling against Dzungar rule joined the Qing in their war against the Dzungars. The Yarkent Khanate under Muhammad Amin Khan presented tribute to the Qing dynasty twice to request aid against the Dzungar attack. The Dzungars used the Zamburak, camel mounted miniature cannons, in battle, notably at Ulan Butung. Gunpowder weapons like guns and cannons were deployed by the Qing and the Dzungars at the same time against each other. The First Dzungar–Qing War was a military conflict fought from 1687-1697 between the Dzungar Khanate and an alliance of the Qing dynasty and the northern Khalkhas, remnants of the Northern Yuan dynasty. The war resulted from a Dzungar attack on the Northern Yuan dynasty based in Outer Mongolia, who were heavily defeated in 1688. Their rulers and twenty thousand refugees fled south to the Qing dynasty, which feared the growing power of the Dzungar state. Motivated by the opportunity to gain control over Mongolia and by the threat posed to them by a strong, unified Mongol state such as the Oirats threatened to form, the Qing sent their army north to subdue the Dzungars in 1690. Qing scouts attacked a Dzungar party north of the Great Wall. However, this proved to be the main Dzungar army, which destroyed the Qing detachment easily. A large Qing army under Prince Fuquan advanced North into Inner Mongolia, hoping to trap and crush the mobile Dzungar army.