When the British relinquished their claims to paramountcy, the 562 Independent princely states were given the option to join either of the two nations. Afew princely states readily joined Pakistan, but the rest - except Hyderabad (the largest of the princely states with 132,000 square kms and a populastion of more than 14 million), Jammu and Kashmir (with 3 million inhabitants)and Junagadh (with a population of 545,000)- merged with India.The hindu maharaja of Predominantly muslim Jammu and Kashmir remained uncommitted until armed tribesmen and regular troops from Pakistan infiltrated his domain, inducing him to sign the instrument of accession to India on Oct 27,1947. Pakistan refused to accept the accession, and as a result, war broke.The first test of the Indian armed forces came shortly after independence with the first Indo-Pakistan conflict( 1947-1948). The military was called upon to defend the borders of the state of Jammu and Kashmir when Tribals- principally Pathans -attacked from the north-west reaches of Kashmir on Oct 22, 1947. India's 161st Infantry Brigade was deployed and thwarted the advance of the tribal forces , in early Nov 1947, th 161st counter attacked and successfully broke through the enemy defenses . Despite early successes, the Indian army suffered a setback in Dec because of logistical problems. The problems enabled the forces of Azad kashmir (Free Kashmir , as the part of Kashmir under Pakistani control) to take the initiative and forced the Indian troops to retreat from border areas. In the spring of 1948, the indian side mounted another offensive to retake some of the ground that it had lost. No doubt fearing that the war might move into Pakistan proper, regular units of the of the Pakistani army became more actively involved. As the conflict escalated , the Indian leadership was quick to recognize that war could not be brought to a close unless Pakistani support for the Azad Kashmir forces could be stopped. Accordingly, on the advice of Governor-General Mountbatten , the Indian Govt. sought United Nations mediation of the conflict on Dec 31 1947. There was some opposition to this move to this move withinthe cabinet by those who did not want to refer the matter to UN. The UN, brought nthe war to a close on Jan 1, 1949, in all 1,500 soldiers died on each side during the war..