Former U.S. President Barack Obama received an exuberant welcome in Berlin as he took part in a public debate together with Chancellor Angela Merkel.
Obama and Merkel appeared on a podium at the German capital's iconic Brandenburg Gate before thousands of people attending a May 25 gathering marking the 500th anniversary of the Protestant Reformation.
Security was tight, with police helicopters patrolling the skies and snipers with balaclavas watching the scene from rooftops.
Obama praised Merkel as someone who had done "outstanding work," and defended his own presidency and the values of liberal democracy that both he and the German leader have championed.
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 swipe at his successor, U.S. President Donald Trump, Obama also spoke of the need to see development aid and diplomacy as essential parts of national security policy.
"We can't isolate ourselves. We can't hide behind a wall," he said, to cheers from the audience.
Merkel, who hosted Obama at the same spot four years ago, was due to travel to Brussels later on May 25 for a meeting with leaders of fellow NATO member states, including Trump.
Merkel's appearance with Obama was criticized by some German opposition politicians as a publicity stunt ahead of elections in September.