Mr Miliband (r) meets Foreign Minister Shah Mahmood Qureshi
UK Foreign Secretary David Miliband has given his public support to the Pakistani government's efforts to negotiate with Islamist militants.
But he insisted that talks should only be held with militants prepared to renounce violence.
"Reconciliation does not mean creating safe space for terrorists," he told journalists in Islamabad.
He was speaking after meetings with Prime Minister Yusuf Raza Gillani and President Pervez Musharraf.
BBC diplomatic correspondent James Robbins says Mr Miliband very deliberately praised Pakistan's new and still fragile coalition government, which is setting out on a long road to show democratic civilian rule can succeed and survive in Pakistan in the face of extremism and major economic challenges.
Mr Miliband had dinner with Nawaz Sharif and Asif Zardari, bitter enemies over many years who have come together in the current coalition.
Mr Miliband said he was humbled to sit next to them and hear them talk of their commitment to each other and to democracy.
But our correspondent says Mr Miliband did not deny the immense challenges facing the new coalition and the people of Pakistan.
He said there was clear evidence of a continuing al-Qaeda presence on both sides of Pakistan's border with Afghanistan.
Britain supports Pakistan's commitment to seek reconciliation with extremists willing to work within the constitution, but Mr Miliband also gave a clear warning to those in Pakistan who argue that the army should not confront the extremists in a war widely blamed on the US.
"Reconciliation means dividing those ideologically committed to wage a war against this country or other countries and those able to play by non-violent constitutional rules," he said.
"It is about building stability and prosperity."
Mr Miliband has been emphasising the importance of the fight against extremists for the people of Britain and Pakistan.
Militants must adopt non-violence, Mr Miliband said
He told the BBC that 70% of the terror plots now being investigated in the UK had links that could be traced back to Pakistan.
Mr Miliband also backed Pakistan's readmission to the Commonwealth.
Earlier on his visit to Pakistan, Mr Miliband said he hoped the new government would build a stable coalition "which will last for the full four or five years with a programme that takes Pakistan forward".
Pakistan's new prime minister is a member of the Pakistan People's Party (PPP), whose leader Benazir Bhutto was assassinated in December.
He was sworn in as prime minister in March at the head of a coalition between the PPP and the Pakistan Muslim League-Nawaz.
Mr Gillani immediately said the government was willing to talk to militants who laid down their arms and he announced measures that could lead to integrating Pakistan's lawless tribal areas into the rest of the country.
He promised to reduce perks for government ministers and also lifted a ban on student and trade unions, abolished more than two decades ago.
The parties' success in the 18 February general election was seen as a blow to President Musharraf.