KRUN, Germany — Before he sat down with the leaders of the seven largest industrialized democracies here Sunday, President Obama met with German Chancellor Angela Merkel, a sign of how important their sometimes strained relationship has become to his presidency.

Obama toured a small Bavarian village with the German chancellor, and he kept the mood light. The president praised the alphorn music that greeted his arrival, drank a beer and joked about needing some lederhosen. Then the two leaders discussed for about 45 minutes some of the thorniest and most important foreign policy problems Obama faces in the fourth quarter of his presidency.

The list included the financial crisis in Greece, sanctions designed to punish Russia for its aggression in Ukraine and two issues Obama views as critical to his legacy: progress against climate change and the passage of free-trade agreements in Asia and in Europe. Merkel’s support will be critical in all of those endeavors.

“Merkel is the European leader he openly admits he’s been probably the closest to, and yet that relationship has really weathered a number of storms over the last year,” said Julianne Smith, a former deputy national security adviser in the Obama administration and a senior fellow at the Center for a New American Security.

Germans were outraged in 2013 after information released by whistleblower Edward Snowden showed that the National Security Agency was monitoring U.S. allies’ communications, including those of Merkel. The scandal resurfaced last month when new revelations suggested that Berlin’s foreign intelligence agency, known as the BND, might have helped the United States gather intelligence on hundreds of European companies and politicians.

The result has been a “spike in anti-Americanism,” said Heather Conley, a senior vice president at the Center for Strategic and International Studies.

In her public remarks, Merkel referred generally to “differences of opinion” with the United States but said the two countries shared an essential partnership based on “mutual interests.”

White House press secretary Josh Earnest said the sensitive surveillance issues did not come up in Obama’s meeting with Merkel. Instead the two leaders, both pragmatists when it comes to foreign policy, focused on areas in which they could cooperate.

Obama needs Merkel’s help most acutely in Ukraine, where Russian separatists recently launched a new offensive.