This resulted in an invasion of Ladakh by Tibet. Kashmir helped to restore Ladakhi rule, on the condition that a mosque be built in Leh and that the Ladakhi king convert to Islam. The Treaty of Temisgam in 1684 settled the dispute between Tibet and Ladakh, but its independence was severely restricted.