When India and Pakistan became separate and independent nations in August of 1947, theoretically they were divided along sectarian lines. In the Partition of India, Hindus were supposed to live in India, while Muslims lived in Pakistan. However, the horrific ethnic cleansing that followed proved that it was impossible to simply draw a line on the map between followers of the two faiths - they had been living in mixed communities for centuries. One region, where the northern tip of India adjoins Pakistan (and China), chose to opt out of both new nations. This was Jammu and Kashmir.
As the British Raj in India ended, Maharaja Hari Singh of the princely state of Jammu and Kashmir refused to join his kingdom to either India or Pakistan. The maharaja himself was Hindu, as were 20% of his subjects, but the overwhelming majority of Kashmiris were Muslim (77%). There were also small minorities of Sikhs and Tibetan Buddhists.
Hari Singh declared Jammu and Kashmir's independence as a separate nation in 1947, but Pakistan immediately launched a guerrilla war to free the majority-Muslim region from Hindu rule. The maharaja then appealed to India for aid, signing an agreement to accede to India in October of 1947, and Indian troops cleared the Pakistani guerrillas from much of the area.
The newly-formed United Nations intervened in the conflict in 1948, organizing a cease-fire and calling for a referendum of Kashmir's people in order to determine whether the majority wished to join with Pakistan or India. However, that vote has never been taken.
Since 1948, Pakistan and India have fought two additional wars over Jammu and Kashmir, in 1965 and in 1999. The region remains divided and claimed by both nations; Pakistan controls the northern and western one-third of the territory, while India has control of the southern area. China and India both also claim a Tibetan enclave in the east of Jammu and Kashmir called Aksai Chin; they fought a war in 1962 over the area, but have since signed agreements to enforce the current "Line of Actual Control."
Maharaja Hari Singh remained head of state in Jammu and Kashmir until 1952; his son later became the governor of the (Indian-administered) state. The Indian-controlled Kashmir Valley's 4 million people are 95% Muslim and only 4% Hindu, while Jammu is 30% Muslim and 66% Hindu. Pakistani-controlled territory is almost 100% Muslim; however, Pakistan's claims include all of the region including Aksia Chin.
The future of this long-disputed region is unclear. Since India, Pakistan and China all possess nuclear weapons, any hot war over Jammu and Kashmir could have devastating results.