Barack Obama received a rock-star welcome in Berlin as he appeared at a public debate Thursday with Chancellor Angela Merkel, whom he praised as one of his "favorite partners" during his presidency.
Security was tight in front of the German capital's iconic Brandenburg Gate, where Obama and Merkel appeared on a podium before thousands of people attending a gathering marking the 500th anniversary of the Protestant Reformation. Police helicopters patrolled the skies and snipers with balaclavas watched the scene from nearby rooftops.
After lauding Merkel as someone who had done "outstanding work," Obama launched a defense of his own presidency and the values of liberal democracy championed by both leaders.
Citing the rise of nationalism and xenophobia in parts of the world, Obama told the crowd that "we have to push back against those trends that would violate human rights or suppress democracy or restrict individual freedoms."
In a veiled reference to his successor Donald Trump, Obama also spoke of the need to see development aid and diplomacy as essential aspects of national security policy.
"We can't isolate ourselves. We can't hide behind a wall,'' he said, to cheers from the audience.
WATCH: Obama on refugees
Merkel, who hosted Obama at the same spot four years ago, was due to travel to Brussels later Thursday for a meeting with leaders of fellow NATO member states, including President Trump.
Thursday's appearance with Obama was criticized by some German opposition politicians as a publicity stunt ahead of September's general election, in which Merkel aims to win a fourth term.