David Cameron announced £650 million in assistance for Pakistani education today, as part of an effort to launch a "fresh start" in Britain's relationship with the south Asian country.
But in a blunt warning to his hosts, the Prime Minister anticipated anger at home at handing over such large sums at a time when schools in the UK are facing cuts.
At a time of austerity, it is difficult to persuade British taxpayers that hundreds of millions of pounds in aid money should go to a country suffering from "weaknesses in terms of government capacity and waste", he said.
And he called on Pakistan to reform its own tax system in order to be able to make better provision for its own public services.
British officials made clear that the new aid money is dependent on Pakistan - which has 17 million children not in school - showing it is spending it effectively.
Cash to train 90,000 teachers, build or refurbish 8,000 schools and provide six million text-books will be "backloaded", so the first year's funding of £60 million will be followed by significantly larger tranches only if it shows results.
The Government's commitment to increase overall aid to 0.7% of GDP has faced resistance from Conservative backbenchers, and eyebrows were being raised at the hike in help for Pakistan at a time when the country is buying six state-of-the-art submarines from China.
Following talks today with his opposite number, Yusuf Raza Gilani, during his first visit to Pakistan as Prime Minister, Mr Cameron insisted he would "struggle to think of a better example" of a country where aid spending was in Britain's national interests, as it would help prevent radicalisation and excessive migration.
But in a later speech to the Islamabad Institute of Information Technology, he said: "Back in the UK, we are taking some incredibly tough economic decisions.
"We are cutting some public spending and increasing some taxes.
"And, understandably, the British people want to know every penny we spend is going to the right places. I need to convince them that it is.
"But my job is made more difficult when people in Britain look at Pakistan, a country that receives millions of pounds of our aid money, and see weaknesses in terms of government capacity and waste."
Mr Cameron pointed out that Pakistan currently spends only 1.5% of national income on education.
And it is has one of the lowest tax revenues, compared with the size of its GDP, of any country in the world.
"You are not raising the resources necessary to pay for things that a modern state and people require," he said.
"Too few people pay tax. Too many of your richest people are getting away without paying much tax at all - and that's not fair.
"Not fair on you, ordinary Pakistanis, who suffer at the sharpest end of this weak governance.
"But neither is it fair on British taxpayers, who are contributing to Pakistan's future.
"It's up to you to decide how far, but Pakistan needs a push for reform."
Today's trip was designed to patch up UK-Pakistan relations, following a spat last year when Mr Cameron accused Islamabad of turning a blind eye to the export of terror.
In a press conference with Mr Gilani, he faced tough questioning from Pakistani journalists over his "obnoxious" comments, limits on student visas, Britain's refusal to extradite former president Pervez Musharraf and the reportedly shaky position of Muslim Cabinet minister Baroness Warsi.
Mr Cameron hailed the work done by Lady Warsi, who was accompanying him on the trip, but did not explicitly guarantee that she was safe in the expected Government reshuffle.
Mr Cameron and Mr Gilani signed an Enhanced Strategic Dialogue document including a pledge to increase trade to £2.5 billion by 2015.
And the first meeting of the UK-Pakistan National Security Dialogue was held, bringing together military and intelligence chiefs with political leaders from both sides.
Plans were announced for a UK/US/Pakistan Centre of Excellence to train Pakistani security agents in dealing with IEDs (improvised explosive devices) - the roadside bombs used by Taliban militants to cause death and destruction in Pakistan's tribal areas and neighbouring Afghanistan.
The centre, in the garrison town of Risalpur, near Peshawar in north-western Pakistan, will provide training in detection and forensic investigation of IEDs as well as bomb disposal and measures to break up bomb-planting networks.
The heightened security co-operation is a mark of London's belief that, following years in which its ISI intelligence agency was suspected of support for the Taliban, Pakistan is now serious about the need to clamp down on militancy.
In his speech, Mr Cameron said he "saluted the resilience of the Pakistani people" after 3,000 terror deaths in the last year alone.
"It's a tragic fact that, in the past year, over 3,000 Pakistani civilians have lost their lives in terrorist attacks," he said.
"And even more of your own soldiers and security forces have died fighting this same extremism here in Pakistan than the international forces have lost in Afghanistan...
"Few countries have suffered at the hands of this terrorism like yours - as we saw again this weekend, with the cowardly attack which murdered dozens of innocent people at the Sakhi Sarwar shrine.
"And no country is more ready to stand with you in your fight against this terrorism than Britain...
"That's why it's right that neither the Pakistan army nor Nato forces must ever tolerate sanctuaries for people plotting violence."
Radicalisation is a "shared problem" which Britain and Pakistan have to tackle together, he said. Britain will stand "four square" behind those trying to build a more democratic Pakistan and will always support the country's civil society.
Mr Cameron said he intended his visit to mark "a new chapter in the relationship between our two countries".
Britain wants "a strong relationship with a secure, prosperous, open and flourishing Pakistan", he said.
In a tacit acknowledgement of the fury provoked in Pakistan by his comments during a visit to neighbour and rival India last July, he said it was time to "clear up the misunderstandings of the past, work through the tensions of the present and look together to the opportunities of the future".
He added: "I acknowledge that there are challenges that our friendship must overcome. But I want to argue today that they shouldn't hold us back any more."