 The Treaty of Temisgam in 1684 settled the dispute between Tibet and Ladakh, but its independence was seriously restricted.The Namgyal dynasty ended in 1842 after a surprise invasion of Ladakh from the Maharaja ranjit singh of punjab.By the beginning of the 19th century, the Mughal empire had collapsed and Sikh rule had been established in Punjab and Kashmir.