The agreement aims to prevent global temperatures from rising more than two degrees above pre-industrial levels.
The heads of the world's biggest economies further agreed to enable an economy without the use of fossil fuels "in the course of this century".
Merkel and French President Francois Hollande pushed their G7 counterparts to reach consensus on climate change, ahead of the crunch year-end United Nations summit in Paris.
The leaders stressed that "deep cuts in global greenhouse gas emissions" were required with "a decarbonisation of the global economy over the course of this century."
The aim was to send a clear signal to push other nations taking part in the Paris meeting to commit to reducing dangerous greenhouse gas emissions, which threaten to melt ice caps and glaciers, raise sea levels and bring more violent storms and floods.
Under the agreement, the G7 countries oblige themselves to reach the "upper end" of the 40-70 percent reduction in electricity generation using coal and oil by 2050 recommended by the Intergovernmental Panel on Climate Change (IPCC).
The move falls short of the total removal of coal by 2050 hoped for by some climate activists.
Russia still shut out
"We ... stand ready to take further restrictive measures in order to increase cost on Russia should its actions so require," said the leaders in a joint communique after the two-day huddle.
"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," the leaders added, referring to a peace deal struck in the Belarus capital.
The tough line from the world's power brokers came as Ukraine's defence minister accused pro-Russian rebels - backed by Moscow - of deploying an army of 40,000 men on the Ukrainian border.
The force threatening Kiev was equivalent to that of a "mid-sized European state", said Stepan Poltorak.
Clashes in recent days between the Ukrainian forces and the separatists have threatened the ceasefire deal thrashed out in Minsk.
Jihad and chicken soup
The leaders also sought to thrash out other threats to global security over a lunch of Thai chicken soup, trout and a peach dessert with almonds.
In an unusual move, the G7 leaders invited the heads of countries threatened by jihadist groups, including the leaders of Nigeria and Iraq, both battling deadly insurgencies.
Iraq's Prime Minister Haider al-Abadi was invited to discuss the US-led campaign to help his country fight the Islamic State extremists who launched a lightning offensive a year ago and have snatched over a third of the country's territory.
Abadi also got one-on-one time with Obama to discuss the Washington-led campaign to help Baghdad recover territory lost to IS militants, whose self-proclaimed "caliphate" extends deep into neighbouring Syria.
Another visitor to the summit, Nigeria's newly elected President Muhammadu Buhari, put a "shopping list" to the G7 leaders, seeking help to fight an insurgency by Boko Haram Islamists blamed for 15,000 deaths since 2009.
Buhari has been tested with 11 separate attacks that have left at least 93 dead in the week he has been in the job.
"We reaffirm our commitment to defeating this terrorist group and combatting the spread of its hateful ideology," said the leaders, in reference to the Islamic State group.
Greece rears its head
Another pressing problem has been the haggling between debt-hit Greece and its international creditors and the fear that a messy default could lead to Greece exiting the eurozone, with unknown repercussions for the world economy.
The issue arose again when the G7 leaders met another guest in their "outreach talks" Monday, International Monetary Fund chief Christine Lagarde.
Merkel warned "we don't have much more time" to resolve the debt crisis, with Athens and its creditors - the International Monetary Fund, the European Union and European Central Bank - having been locked in negotiations for five months on reforms needed to unlock €7.2 billion in rescue funds that Athens desperately needs.
Earlier on Monday, anti-G7 demonstrators camped in the nearby town of Garmisch-Patenkirchen said that they had cancelled a planned march due to exhaustion.
'Stop G7 Elmau' spokeswoman Ingrid Scherf said that the march was cancelled "because we already walked so far yesterday."
On Sunday, the anti-globalization group had tried to get closer to the summit venue in Elmau castle in the Bavarian Alps.
But the walk up and down mountains and along hiking trails left them too tired to take part in a planned 500-person demonstration in the town where they have been camping.