David Cameron has said he wants a "fresh start" in relations with Pakistan as he offered £650m in aid and better security co-operation.
On his first trip to Pakistan since becoming UK prime minister, he said he wanted to foster mutual trust.
Last year he provoked anger when he accused elements in Pakistan of promoting the "export of terror".
On Tuesday, he pledged to create a "new era" and to "clear up the misunderstandings of the past".
At a news conference with the Pakistani prime minister Yousuf Raza Gilani, Mr Cameron said he believed the Pakistani government was committed to fighting terrorism within its borders but said it was "not unhelpful" to urge its ally to do everything it could to tackle the threat.
"What you see in Pakistan today is a huge fight taking place by the government against terrorism and Pakistan has lost many, many people in that fight," he said.
After taking part in the first meeting of the UK-Pakistan National Security Dialogue - a civilian and military counter-terrorism forum - Mr Cameron said there would be increased co-operation at the "sharp end" to disrupt the work of terrorist groups.
"We have no higher shared priority than tackling terrorism together," he added.
"That means challenging the extremist ideology that fuels it and ensuring effective operational co-operation between our police and intelligence agencies."
He was criticised last year for claiming that Pakistan "looked both ways" when it came to the issue.
On Tuesday he said: "Let us make this the start of a new era in the relations between our countries, our governments and our peoples. Let us clear up the misunderstandings of the past, work through the tensions of the present and look together to the opportunities of the future.
"A Pakistan that is safe for its citizens, free from the threat of terror on your doorstep and in your neighbourhood, a Britain working alongside you for our mutual benefit."
The BBC's deputy political editor, James Landale said Mr Cameron was offering to share the UK's expertise in fighting roadside bombs at a new centre being established in Pakistan.
The site, near Peshawar in the north-west of the country, will provide training in detection and forensic investigation of improvised explosive devices (IEDs) as well as bomb disposal.
British officials have played down fears of links between the Pakistani security services and the Taliban, James Landale added, insisting they were no longer providing support to the insurgency in Afghanistan and were committed to defeating them both in Afghanistan and Pakistan.
Mr Cameron is being accompanied on his trip by the head of the armed forces, General Sir David Richards head of MI6, Sir John Sawers.
The prime minister, who earlier visited a school and Pakistan's national mosque, also pledged £650m of additional aid for Pakistan's schools system.
He said the four-year package of support would help an extra four million children go to primary schools, train an extra 90,000 teachers and provide six million text books.
He defended the initiative, at a time when spending on public services including education is being cut in the UK, as an "investment for Britain".
"I would struggle to find a country that is more in Britain's interests to see progress and succeed than Pakistan," he added. "If Pakistan is a success, we will have a good friend to trade with and deal with in the future.
"If we fail, we will have all the problems of migration and extremism that we don't want to see. It is in our interests that Pakistan succeeds."
But he warned that Pakistan must do more to provide for their own public services, including tax reform and making the rich pay more.
Mr Gilani said illiteracy was at the "root cause" of extremism, adding that Pakistan had paid a "heavy price" for its fight against terrorism - losing 30,000 people to domestic attacks.
More broadly, Mr Cameron said there was no question about the strength of UK-Pakistan links.
"Britain's friendship with Pakistan is unbreakable," he said. "From the grassroots links between our peoples, with [the] one million-strong Pakistan diaspora in the UK and 1.4 million journeys between Pakistan and the UK every single year."
The two leaders also agreed to seek to double bilateral trade to £2.5bn by 2025.