Ministers from the world's richest democracies have agreed to work to phase out coal-power, although they failed to set a date for doing so.
They also said the energy crunch brought on by the Russia-Ukraine war should not derail efforts to fight climate change.
The commitment, published at the end of three days of Group of Seven talks in Berlin, was weaker than a previous draft of the final communique seen by Reuters, which had included a target to end unabated coal power generation by 2030.
Sources familiar with the discussions said Japan and the United States had both indicated they could not support that date.
But the pledge still marked the first commitment from the G7 countries to quit coal-fuelled power. Coal is the most CO2-emitting fossil fuel and its use needs to plummet if the world is to avoid the worst impacts of climate change.
The group met against the backdrop of spiralling energy costs and fuel supply worries due to the war in Ukraine. The conflict has triggered a scramble among some countries to buy more non-Russian fossil fuels and burn coal to cut their reliance on Russian supplies.
"Replacing fossil fuels from Russia has dominated the political debate and the actions of the government in the past weeks and months," German economy minister Robert Habeck said at a news conference.
"But it must be clear to us that the challenges of our political generation, limiting global warming, won't go away if we just concentrate on the present," he said. "Time is literally running out."
The G7 also agreed to largely decarbonise their power sectors by 2035, and to stop public financing for "unabated" fossil fuel projects abroad by the end of this year, except in limited circumstances. "Unabated" refers to power plants that do not use technology to capture their emissions.
The communique made a commitment to a highly decarbonised road sector by 2030, including significantly increasing the sale, share and uptake of zero emission light duty vehicles.
The G7 also aimed to start reporting publicly next year on how the countries are delivering on a past commitment to end "inefficient" fossil fuel subsidies by 2025.
All G7 countries except for Japan had made the finance pledge at the COP26 climate summit last year, and campaigners said it would be a significant shift if Japan - one of the world's biggest providers of finance for fossil fuel projects abroad - came on board.
"If Japan implements this commitment with integrity, it will directly shift $11 billion a year from fossil fuels to clean energy and have a much larger indirect impact given Japan's influence on other financiers in Asia and around the world," said Susanne Wong, Asia program manager at Oil Change.
By covering all fossil fuels, including oil and gas, the agreement goes further than a pledge made by G20 countries last year to halt overseas financing for just coal.
The G7 also pledged to take ambitious action against plastic pollution and to increase national efforts to conserve or protect at least 30 per cent of their own coastal and marine areas by 2030.
Australian Associated Press
Sign up for our newsletter to stay up to date.