KRUN, Germany - Before he sat down with the leaders of the seven largest industrialized democracies here on 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 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 is facing in the fourth quarter of his presidency.

The list included the financial crisis in Greece, sanctions against Russia, 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 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. About half of his meeting with Merkel was focused on the way forward in what increasingly looks like a stalemated conflict, in which Russian President Vladimir Putin seems to believe that if he can hold out long enough, the resolve of Ukraine's European allies will fracture.

Obama's message Sunday to the European allies, which would need to renew the sanctions at a meeting later this month, was to "stay vigilant" and focused.

That is where Merkel will be crucial. She is the Western leader with the closest relationship with Putin. Less clear is what the White House and the allies will do if the increasingly fragile peace in Ukraine crumbles entirely.