"We commit to end new direct public support for the international unabated fossil fuel energy sector by the end of 2022," G7 energy and climate ministers said in a joint statement following talks in Berlin.
The term "unabated" refers to projects that do not employ techniques to offset some of the pollution caused by carbon dioxide emissions.
Ending subsidies for the international fossil fuel energy sector was already part of a series of commitments agreed to by around 20 countries at last year's COP26 climate summit in Glasgow.
Six of the G7 club of rich nations were among the signatories at the time - Britain, Canada, Germany, France, Italy and the United States - but Japan had resisted until now.
"It is good that Japan, the world's largest financier of fossil fuels, has now joined the other G7 countries in making a shared commitment to end overseas fossil fuel financing," said Alden Meyer, senior associate at climate policy think tank E3G.
Friday's pledge still allows for some "limited" exceptions of fossil-fuel financing so long as they are consistent with the 2015 Paris pact to curb global temperature increases. But Meyer said countries wishing to do so would face "a very stiff bar to clear".
At their G7 talks, ministers also committed to largely end the use of fossil fuels in their electricity sectors by 2035, despite heavy tensions in the power market over Russia's invasion of Ukraine.
"We further commit to a goal of achieving predominantly decarbonised electricity sectors by 2035," they said.
To achieve this, member states promised to ramp up "the necessary technologies and policies for the clean energy transition" and accelerate the phase-out of coal.
The pledge was welcomed by environmental campaigners, at a time when the war in Ukraine has sent energy prices soaring and Western countries are scrambling to wean themselves off Russian imports.
"In a very difficult geopolitical situation, the G7 are united behind an end to fossil fuels by 2035 in the power sector. This is significant progress," said David Ryfisch of the Germanwatch environmental group.
Speaking at the closing press conference, German Energy Minister Robert Habeck welcomed the pledges made by G7 nations, saying they sent a "strong signal for more climate protection".
As well as a pledge to stop bankrolling fossil fuel projects abroad by the end of the year, Habeck highlighted the club's agreement to ditch all "inefficient fossil fuel subsidies" by 2025.
"That we reward climate-damaging behaviour, either through direct subsidies or through tax advantages ... is absurd and this absurdity has to stopped," he told reporters.
According to the International Energy Agency (IEA), in order to maintain the goal of capping global warming at 1.5 degrees Celsius, all financing of new fossil fuel projects must be stopped immediately.
The Oil Change International campaign group has calculated that between 2018 and 2020, G20 countries alone provided US$188 billion in financing for overseas oil, coal and gas projects.