It is not every day that a prime minister stands up and accuses an ally of promoting terrorism. But that is exactly what David Cameron did on the first day of his visit to India last July when he said that Pakistan could not be allowed to "look both ways" on terrorism.

I was sitting in the audience in a large hall at the Infosys IT company campus in Bangalore on 28 July last year when the prime minister said in public what British officials have been saying in private for years.

Officials accompanying the prime minister were astonished by his remarks and knew Cameron would have to make amends with Pakistan. It took just over eight months for him to travel to Islamabad last month to declare that Britain and Pakistan have "an unbreakable partnership".

Now we know what was on Cameron's mind on that day during the south Indian monsoon last July. Exactly a week before his arrival in India, the prime minister had been told in Washington of the continuing terrorist threat from Pakistan.

During his first visit to Washington as prime minister, Cameron was given a briefing on Afghanistan and Pakistan by General James Cartwright, vice-chairman of the joint chiefs of staff. Cartwright reinforced a message to Cameron from Barack Obama – that elements of the Pakistan state, notably the ISI intelligence agency, were at the very least tolerating terrorism.

That is why Cameron told his Bangalore audience:

We cannot tolerate in any sense the idea that this country is allowed to look both ways and is able, in any way, to promote the export of terror, whether to India or whether to Afghanistan or anywhere else in the world.

That is why this relationship is important. It should be a relationship based on a very clear message: that it is not right to have any relationship with groups that are promoting terror. Democratic states that want to be part of the developed world cannot do that. The message to Pakistan from the US and the UK is very clear on that point.

It is now clear that the prime minister was not just told in Washington that organisations like Lakshar e Taiba were able to launch attacks on India and Britain from Pakistan. Cameron was also warned that Pakistan was providing a haven for al-Qaida leaders, possibly including Osama bin Laden.

The prime minister would not have been told that bin Laden was living in the comfortable garrison town of Abbottabad 35 miles from Islamabad and less than a mile from the Pakistani military's main training academy. That is because the US authorities did not track bin Laden to the compound until last August, shortly after Cameron's trips to India and Washington, according to the New York Times.

But the US authorities had been familiar with al-Qaida's links to Abbottabad for at least two years. We know this because one of the leaked Guantanamo files published on 25 April by the Guardian which is dated 10 September 2008. This shows that a Guantanamo detainee, who allegedly provided intelligence which led the US authorities to one of bin Laden's couriers, moved his family to Abbottabad in the middle of 2003.

It was not clear tonight whether the courier named in the file was the man who inadvertently led the US authorities to bin Laden. But the Washington Post reported this evening that the hunt for the courier began with the detention six years ago today of the detainee named in the Guantanamo file.

The intelligence about Abbottabad shows that the US knew that al-Qaida figures were sheltering in areas outside the tribal border areas where the writ of the Pakistani state often does not run. William Hague told the Today programme this morning that there had been a "general assumption" that bin Laden was hiding in the mountainous tribal areas.

But Britain had been briefed that al-Qaida figures were sheltering in parts of Pakistan where the state's writ does run. Khalid Sheikh Mohammed, the alleged mastermind of the 9/11 attacks, was after all captured by the Pakistani authorities in Rawalpindi, close to Islamabad, on 1 March 2003.

The prime minister, who was woken in the early hours of Monday morning at Chequers to be informed by Barack Obama of the death of bin Laden, chaired a meeting of COBR at 8.00pm this evening. The prime minister summoned senior ministers after telephoning Asif Ali Zardari, the president of Pakistan, and Yousuf Raza Gilani, the country's prime minister. He also spoke to Hamid Karzai, the Afghan president.

The prime minister was no doubt diplomatic in his telephone calls, not least because of the sensitive relations between Pakistan and Afghanistan. Karzai believes US forces should be concentrating their firepower on al-Qaida and Taliban forces in Pakistan.

But Cameron may have been tempted to tell Pakistan's leaders that some of his worst fears about the presence of terrorists within its borders have now come true.