Three weeks ago, in the Kashmiri capital of Srinagar, I met a young surgeon named Dr Iqbal Saleem. Iqbal described to me how on 11 August this year, Indian security forces entered the hospital where he was fighting to save the lives of unarmed civilian protesters who had been shot earlier that day by the Indian army. The operating theatre had been tear-gassed and the wards riddled with bullets, creating panic and injuring several of the nurses. Iqbal had trained at the Apollo hospital in Delhi and said he harboured no hatred against Hindus or Indians. But the incident had profoundly disgusted him and the unrepentant actions of the security forces, combined with the indifference of the Indian media, had convinced him that Kashmir needed its independence.

I thought back to this conversation last week, when news came in that the murderous attackers of Mumbai had brutally assaulted the city's hospitals in addition to the more obvious Islamist targets of five-star hotels, Jewish centres and cafes frequented by Americans and Brits. Since then, the links between the Mumbai attacks and the separatist struggle in Kashmir have become ever more explicit. There now seems to be a growing consensus that the operation is linked to the Pakistan-based jihadi outfit, Lashkar-e-Taiba, whose leader, Hafiz Muhammad Sayeed, operates openly from his base at Muridhke outside Lahore.

This probable Pakistani origin of the Mumbai attacks, and the links to Kashmir-focused jihadi groups, means that the horrific events have to be seen in the context of the wider disaster of Western policy in the region since 9/11. The abject failure of the Bush administration to woo the people of Pakistan and Afghanistan away from the Islamists and, instead, managing to convince many of them of the hostility of the West towards all Muslim aspirations, has now led to a gathering catastrophe in Afghanistan where the once-hated Taliban are now again at the gates of Kabul.

Meanwhile, the blowback from that Afghan conflict in Pakistan has meant that Asif Ali Zardari's government has now lost control of much of the North West Frontier Province, in addition to the Federally Administrated Tribal Areas, while religious and political extremism flourishes as never before.

Pakistan's most intractable problem remains the relationship of Inter-Services Intelligence (ISI) over the last 25 years with myriad jihadi groups. Once, the ISI believed that they could use jihadis for their own ends, but the Islamists have increasingly followed their own agendas, to the extent that they now feel capable of launching well-equipped and well-trained armies into Indian territory, as happened so dramatically in Mumbai.

Visiting Pakistan last week, it was clear that much of the north of the country was slipping out of government control. While it is unlikely that Zardari's government had any direct link to the Mumbai attacks, there is every reason to believe that its failure effectively to crack down on the country's jihadi network, and its equivocation with figures such as Hafiz Muhammad Syed, means that atrocities of the kind we saw last week are likely to continue.

India meanwhile continues to make matters worse by its ill-treatment of the people of Kashmir, which has handed to the jihadis an entire generation of educated, angry middle-class Muslims. One of the clean-shaven boys who attacked CST railway station - now named by the Indian media as Mohammad Ajmal Mohammad Amin Kasab, from Faridkot in the Pakistani Punjab - was wearing a Versace T-shirt. The other boys in the operation wore jeans and Nikes and were described by eyewitnesses as chikna or well-off. These were not poor, madrasah-educated Pakistanis from the villages, brainwashed by mullahs, but angry and well-educated, middle-class kids furious at the gross injustice they perceive being done to Muslims by Israel, the US, the UK and India in Palestine, Iraq, Afghanistan and Kashmir respectively.

If Israel's treatment of the Palestinians is the most emotive issue for Muslims in the Middle East, then India's treatment of the people of Kashmir plays a similar role among South-Asian Muslims. At the Partition of India and Pakistan in 1947, the state should logically have gone to Pakistan. However, the pro-Indian sympathies of the state's Hindu Maharajah, as well as the Kashmiri origins of the Indian Prime Minister, Jawaharlal Nehru, led to the state passing instead to India - on the condition that the Kashmiris retained a degree of autonomy.

Successive Indian governments, however, refused to honour their constitutional commitments to the state. The referendum, promised by Nehru at the UN, on whether the state would remain part of India, was never held. Following the shameless rigging of the 1987 local elections, Kashmiri leaders went underground. Soon after, bombings and assassination began, assisted by Pakistan's ISI which ramped up the conflict by sending over the border thousands of heavily armed jihadis.

India, meanwhile, responded with great brutality to the insurgency. Half-a-million Indian soldiers and paramilitaries were dispatched to garrison the valley. There were mass arrests and much violence against ordinary civilians, little of which was ever investigated, either by the government or the Indian media. Two torture centres were set up - Papa 1 and Papa 2 - into which large numbers of local people would 'disappear'. In all, some 70,000 people have now lost their lives in the conflict. India and Pakistan have fought three inconclusive wars over Kashmir, while a fourth mini-war came alarmingly close to igniting a nuclear exchange between the two countries in 1999. Now, after the Mumbai attacks, Kashmir looks likely to derail yet again the burgeoning peace process between India and Pakistan.

Kashmir continues to divide the establishment of Pakistan more than any other issue. Zardari might publicly announce that he doesn't want to let Kashmir get in the way of improved relations between India and Pakistan, but Lashkar-e-Taiba, which is officially banned, continues to function under the name of Jama'at al-Dawa, and Hafiz Muhammad Sayeed continues openly to incite strikes against Indian and Western targets. At one recent meeting, he proclaimed that 'Christians, Jews and Hindus are enemies of Islam' and added that it was the aim of the Lashkar to 'unfurl the green flag of Islam in Washington, Tel Aviv and New Delhi'.

Sayeed also proclaims that the former princely state of what he calls 'Hyderabad Deccan' is also a part of Pakistan, which may explain the claim of responsibility for the attacks by a previously unknown group named the Deccan Mujahideen. It is clear Sayeed appears to operate with a measure of patronage from the Pakistani establishment and the Zardari government recently cleared the purchase of a bulletproof Land Cruiser for him. When Pakistan's Foreign Minister, Shah Mehmood Qureshi, was yesterday asked on Indian TV whether Pakistan would now arrest Sayeed, he dodged the question answering: 'We have to recognise that there are elements in every society that can act on their own.'

In the months ahead, we are likely to see a security crackdown in India and huge pressure applied to Pakistan to match its pro-Indian and pro-Western rhetoric with real action against the country's jihadi groups. But there is unlikely to be peace in South Asia until the demands of the Kashmiris are in some measure addressed and the swamp of grievance in Srinagar somehow drained. Until then, the Mumbai massacres may be a harbinger of more violence to come.

• William Dalrymple's Last Mughal won the Duff Cooper Prize and the Crossword Indian Book of the Year prize.