Concessions by Japan's prime minister, Junichiro Koizumi, and the German chancellor, Gerhard Schröder, broke the logjam after talks rolled into the final day of the summit. Mr Koizumi said Japan would increase its aid budget by $10bn over the next five years, while Mr Schröder said he would use a tax on air travel to meet Germany's ambitious aid targets.
With less progress than Britain had hoped for on trade, Tony Blair said the deal on Africa was not all that campaigners wanted but insisted it represented real progress. "There are commitments here that are hugely significant," he said.
Mr Blair said the summit was an advance on anything that had happened before, but recognised that there was more to be done. Britain had wanted to go further on eliminating the export subsidies which allow the west to dump excess produce on global markets, but was forced to compromise. The summit merely committed itself to setting a credible date for scrapping export subsidies, which Mr Blair said he expected to be 2010.
"It isn't the end of poverty in Africa but it is the hope that it can be ended," Mr Blair said.
"It is the definitive expression of our collective will to act in the face of death and disease and conflict that is preventable."
Under the deal, the G8 pledged to increase aid by "around $50bn" (£28bn) a year by 2010. Assistance to Africa will increase by $25bn, more than doubling the flows in 2004.
Britain had feared the G8 leaders would backslide on commitments made by their finance ministers at a meeting in London last month. In the end, however, they endorsed agreement to write off debts owed by up to 28 countries to the World Bank, the African Development Bank and the International Monetary Fund.
UK sources said the communique represented a significant advance and were pleased that the G8 had endorsed a plan for treatment for HIV/Aids by 2010. Although some countries were concerned by the $22bn price tag, the summit said it was aiming to have "as close as possible to universal access to treatment for all those who need it by 2010".
The government source said: "It's a good first step. It's a shame we didn't get a bit further and there's a long way to go. But if six months ago people had thought this would be the outcome of the meeting they would not have been disappointed."
But African leaders and aid agencies were unhappy with the deal.
Mulima Kufekisa, the head of Zambia's justice and peace commission, said: "This is not the historic breakthrough the global campaign was looking for. This was a chance to set Africa on an irreversible path of growth and development. Instead, the G8 have agreed to come up with an additional $20bn but in five years' time. There are still too many countries saddled with unpayable debts."
Christian Aid said it was "a vastly disappointing result. Millions of campaigners from all over the world have been led to the top of the mountain, shown the view and now we are being frogmarched down again."
There was particular disappointment that, despite day after day of meetings between summit officials, or sherpas, the G8 had fallen $2bn short of finding $50bn in extra aid.
"Compared to the amount of money spent by the rich nations on arms alone, $50bn is a tiny amount. Tony Blair said not everyone would be happy and unfortunately he was right," Christian Aid said.
Jo Leadbetter, Oxfam's head of policy, said: "The G8 have recognised that this is the beginning, not the end, of their efforts to overcome poverty. The world's richest nations have delivered welcome progress for the world's poorest people, but the outcome here in Gleneagles has fallen short of the hopes of millions around the world."
John Hilary, the director of campaigns at War on Want, called the summit a betrayal of the 1.1 billion people living on less than a dollar a day.
"The G8 have given less than 10% of our demand on debt cancellation and not even a fifth of what we called for on aid ... When the moment came to act, the G8 turned their backs on the world's poor."