The world should stop using fossil fuels by the end of the century, leaders at the G7 summit have agreed.
German Chancellor Angela Merkel said the Group of Seven wealthy democracies committed themselves to the need to "decarbonise the global economy in the course of this century".
This is a technical term for ending the use of oil, gas and coal - but not nuclear power - and replacing them with alternative sources of energy such as wind and solar power.
Burning carbon-based fuels such as oil and gas releases carbon dioxide into the atmosphere, which is blamed for global warming.
Ms Merkel and French president Francois Holland had pressed for agreement on the goal so it can be put forward at a summit on climate change later this year in Paris.
The aim was to send a signal to push other nations taking part in that meeting to commit to reducing dangerous greenhouse gas emissions.
The countries also committed to limiting the rise in average global temperatures to two degrees Celsius (3.6 Fahrenheit) compared to pre-industrial levels.
The seven countries also agreed at the two-day summit at the Elmau palace in Bavaria to commit to raising $100bn in annual climate financing by 2020 from public and private sources.
In a joint communique issued at the end of the summit, the leaders said: "We commit ourselves to play our part in achieving a low-carbon global economy in the long-term, including by the development and use of innovative technologies and will strive for a restructuring of the energy sector by 2050."
Another issue on the agenda was the Ukraine crisis.
Western nations stand ready to strengthen sanctions against Russia over its involvement in the conflict in the east of the country, Ms Merkel said.
She said the leaders want Russia and Ukraine to comply with a ceasefire agreed in Belarus in February that largely halted fighting between pro-Russian separatists and Ukrainian government forces.
Ms Merkel said: "We are also ready, should the situation escalate, which we don't want, to strengthen sanctions if the situation makes that necessary but we believe we should do everything to move forward the political process of Minsk."
The post-summit communique said: "We ... stand ready to take further restrictive measures in order to increase cost on Russia should its actions so require.
"We recall that the duration of sanctions should be clearly linked to Russia's complete implementation of the Minsk agreements and respect for Ukraine's sovereignty."
Sanctions could be "rolled back" if Moscow lived up to its commitments, the document said.
The current instability in Libya was also discussed, with the G7 leaders urging the country's warring factions to take "bold political decisions" at UN peace talks on Monday, amid concerns the nation is on the verge of collapsing into a failed state.
On the issue of Greece and its financial troubles, Ms Merkel said there is "not a lot of time" to agree a deal on more bailout money to prevent Athens defaulting on its debt repayments to the International Monetary Fund and Central Bank.