The Group of Seven's energy pledge capped a successful summit for host Angela Merkel, who revived her credentials as a "climate chancellor" and strengthened Germany's friendship with the United States at the meeting in a Bavarian resort.
Ties between the Cold War allies have been strained in the last couple of years by spying rows but Merkel appeared to put that behind her on welcoming U.S. President Barack Obama, who declared their countries were "inseparable allies."
Meeting in the picturesque Schloss Elmau at the foot of Germany's highest mountain, the Zugspitze, the G7 leaders pressed Greece to accept painful economic reforms to resolve its debt crisis and struck a firm tone on Russia's role in Ukraine.
They agreed that existing sanctions against Russia would remain in place until Moscow and Russian-backed rebels in eastern Ukraine fully respect a ceasefire negotiated in Minsk in February, and said they could escalate sanctions if needed.
On climate change, the G7 leaders pledged in a communique after their two-day meeting to develop long-term low-carbon strategies and abandon fossil fuels by the end of the century.
"We commit to doing our part to achieve a low-carbon global economy in the long-term, including developing and deploying innovative technologies striving for a transformation of the energy sectors by 2050," the communique read.
The leaders invited other countries to join them in their drive, saying they would accelerate access to renewable energy in Africa and intensify their support for vulnerable countries' own efforts to manage climate change.
The summit revitalised Merkel's green credentials, after concern among diplomats and environmental campaigners that Japan and Canada might torpedo her efforts.
The G7 stopped short of agreeing any immediate collective targets for reducing greenhouse gas emissions, which the Europeans had pressed their partners in the club to embrace. But they said a U.N. climate conference later this year should reach a deal with legal force, including through binding rules, tocombat climate change.
Green lobby groups - routinely critical of the advanced economies' record on climate change - welcomed the thrust of the summit commitments.
"Merkel's G7 says 'Auf Wiedersehen' (farewell) to fossil fuels," global activist network Avaaz declared in a statement.
"Elmau delivered", enthused environmental pressure group Greenpeace, adding that "the vision of a 100 percent renewable energy future is starting to take shape."
The G7 leaders supported a reduction in global greenhouse gas emissions within a range recommended by the United Nations climate change panel, and backed a global target for limiting the rise in average global temperatures to 2 degrees Celsius (3.6 Fahrenheit) compared with pre-industrial levels.
Their accord helps set up the U.N. Paris conference, at which some 200 countries will try to reach agreement on limiting the rise in global temperatues to 2 degrees Celsius and seal a new worldwide agreement to curb greenhouse gas emissions.
The leaders of Britain, Canada, France, Germany, Italy, Japan, the United States and European Union took a firm stance on Russia's involvement in the Ukraine conflict.
Obama and Merkel both said the G7 countries were ready, if necessary, to strengthen sanctions against Moscow.
The leaders want Russia and Ukraine to comply with a Feb. 12 ceasefire agreed in the Belarus capital Minsk that largely halted fighting in eastern Ukraine between pro-Russian separatists and Ukrainian government forces.
"Ultimately this is going to be an issue for Mr (President Vladimir) Putin. He's got to make a decision," Obama told a news conference at the conclusion of the summit.
"Does he continue to wreck his country's economy and continue Russia's isolation in pursuit of a wrong-headed desire to recreate the glories of the Soviet empire, or does he recognise that Russia's greatness does not depend on violating the territorial integrity and sovereignty of other countries?" Obama said Russian forces were operating inside Ukraine,something Moscow continues to deny.
In the communique, the leaders said they expected Russia to stop its support for separatist forces in Ukraine and implement the Minsk agreements in full. The sanctions, they said, "can be rolled back when Russia meets these commitments."
The leaders discussed the Greek debt crisis as a group and also in bilateral meetings. Merkel said Europe was prepared to show solidarity if Athens implemented economic reforms.
Greece's leftist government last week rejected proposals for a cash-for-reforms deal put forward by European lenders and the International Monetary Fund, but has yet to put forward its own alternative to unlock aid funds that expire at the end of June.
"There isn't much time left," Merkel said. "Every day counts now."