Jammu and Kashmir was one of the 550 Princely states given choice to join India or Pakistan way back in 1947

Instrument of Accession of Jammu and Kashmir

Whereas the Indian Independence Act, 1947, provides that as from the fifteen day of August, 1947, there shall be set up as Independent Dominion, known as India and that the Government of India Act, 1935, shall, with such omission, additions, adaptations and modifications as the Governor-General may by order specify be applicable to the Dominion of India;

AND WHEREAS the. Government of India Act, 1935 as so adapted by the Governor-General provides that an Indian State may accede to the Dominion of Indian by an Instrument of Accession executed by the Ruler thereof:

Now Therefore

I. I, Shrirnan Inder Mahendra Rajrajeshwar Maharajadinij Shri Ilan Singh Ji, Ruler of Jammu and Kashmir in the exercise of my sovereignty in and over my said State Do hereby execute this my Instrument of Accession, and
1. I hereby declare that I accede to the Dominion of India with the Intent that the Governor-General of India, the Dominion Legislature, the Federal Court and any, other Dominion authority established for the purposes of the Dominion shall, by virtue of this my Instrument of Accession, but subject always to the terms therefore and for the purpose only of the Dominion, exercise in relation to the State of Jammu and Kashmir (hereinafter referred to as "this Stater) such functions may be vested in them by or under the Government of India Act, 1935 as in force in the Dominion of India on the 15th Day of August, 19,17 (which Act as so in force is hereinafter referred to as "the Act").
2. I hereby assume the obligation of ensuring that due effect is given to the provision of the Act within this State as they are applicable therein by virtue of this my. Instrument of Accession.
3. I accept the matters specified in the schedules here to as the matters with respect to which the Dominion Legislature may make laws for this State,
4. I hereby declare that I accede to the Dominion of India on the assurance that if an agreement is made between the Governor-General and the Ruler of this State where by any functions in relations to the administration in this State of any law of the Dominion Legislature shall be exercised by the Ruler of this State, then any such agreement shall be deemed to form part of this Instrument and shall he construed and have effect accordingly,
5. The terms of this my Instrument of Accession shall not be varied by any amendment of the Act or of the. Indian Independence Act, 1947, unless such amendment is accepted by me by an Instrument supplementary to this Instrument.
6. Nothing in this Instrument shall empower the Dominion Legislature to make any law for this State authorizing the compulsory acquisition of land for any purpose, but I hereby undertake that should the Dominion for the purpose of Dominion law which applies in this State deem it necessary to acquire any land I will at their request acquire the land at their expense or if the land belongs to me transfer it to them on such terms as may be agreed or in default of agreement determined by an arbitrator to be appointed by the Chief Justice of India.
7. Nothing in this Instrument shall be deemed to be a commitment in any way as to acceptance of any future Constitution of India or to fetter my discretion to enter into arrangement with the Governments of India under any such future Constitution.
8. Nothing in this Instrument affects the continuance of my sovereignty in and over this State, or save as provided by or under this Instrument the exercise of any powers, authority and rights now enjoyed by me as Ruler of this State or the validity of any law at present in force in this State.
9. I hereby declare that I execute this Instrument on behalf of this State and that any reference in this Instrument to me or to the Ruler of this State is to be construed as including a reference to my heirs and successors.

Given under my hand this 26th day of October nineteen forty seven.

Sd/- Hari Singh
Maharaja Dhiraj of Jammu and Kashmir

View the document here