Gulab Singh, a Dogra Rajput, entered Ranjit Singh Ji's service as a trooper and was given Jammu as a jagir in 1822. His brothers Dhian Singh and Suchet Singh rose with him. Dhian Singh was wazir at Lahore for years and the family became the most powerful non-Sikh interest in the state.
During the First Anglo-Sikh War Gulab Singh held back from the Khalsa army in the field, and after the defeat he acted as intermediary in the settlement. The Treaty of Amritsar, 16 March 1846, transferred the hill country between the Indus and the Ravi to him for seventy-five lakh rupees. Kashmir, which the Khalsa had taken in 1819, passed out of Punjab's hands into a new princely state.
That transaction created the state of Jammu and Kashmir and is the origin of every dispute over it since.
Jammu city is the winter capital of the union territory. The old Mubarak Mandi palace complex above the Tawi is the Dogra seat and much of it is in poor repair.
The Dogra brothers held Jammu, Bhimber and Rajouri as jagirs, and Gulab Singh took Ladakh and Baltistan in the 1830s and 1840s through Zorawar Singh's campaigns, which reached as far as western Tibet. The territory he bought in 1846 had largely been assembled by him already, on the Lahore state's account and at its expense.
The purchase price was set against the indemnity the Lahore state owed after the first war, which means Kashmir was transferred to settle somebody else's debt.
The state he founded lasted to 1947 and the question of what happened at its end has not been settled since. It began as a transaction in a treaty.
Text of the Treaty of Amritsar, 1846.