This dispute dates back to the partition of the British Indian Empire, in August 1947, into two independent states, Pakistan and India. At that time there were also around 565 princely states, large and small, which were under British suzerainty but were not directly ruled by the British Government. Most of these states joined either India or Pakistan taking into account their contiguity to one or the other country and the wishes of their people.
There were, however, some states over which problems arose, primarily because of India's insatiable desire to grab territory. For example, the Muslim ruler of Junagarh, a state with a Hindu majority population, announced his decision to join Pakistan. India responded by aiding and abetting the establishment of a so-called "Provisional Government" of Junagarh on Indian territory, which attacked Junagarh with Indian connivance and support. Subsequently Indian forces also invaded Junagarh, despite protests from Pakistan, in order to "restore law and order".
A farcical plebiscite was organized under Indian auspices, and India annexed Junagarh. Similarly, in Hyderabad, a Hindu majority state, the Muslim ruler of the state wanted to retain an independent status. India responded by attacking Hyderabad and annexed the state by force. India sought to justify its aggression against Hyderabad and Junagarh on the plea that the rulers of Junagarh and Hyderabad were acting against the wishes of their people.
In Jammu and Kashmir state, the situation was the reverse. The ruler of the State was a Hindu, while the population was overwhelmingly Muslim and wanted to join Pakistan. In this case, India consistently pressurized the Hindu Ruler to accede to India. Apprehending that the Hindu ruler was likely to succumb to Indian pressure, the people of Jammu and Kashmir rose against him, forcing him to flee from Srinagar, the capital of the State.