"A strong and united Europe is a necessity for the world," Obama said in the German city of Hanover, in a landmark speech that carried the tone of a blunt challenge to friends.
Visiting a region reeling from a migration crisis, economic stagnation and facing the prospect of Britain abandoning the European Union, Obama warned that "progress is not inevitable".
Contrasting the prosperity of Europe today with the wars and hardship of the last century, Obama called on Europeans reject the "us-versus-them" politics that has fuelled the rise of the far right in countries from Poland to France.
Hours before he and Chancellor Angela Merkel were to hold talks with the leaders of Britain, France and Italy, Obama painted today's Europeans as heirs to the popular movements that ended the Cold War.
Also Read
And he also recalled the devastating consequences of "intolerance and extreme nationalism" that drenched Europe in blood during the 20th century.
"In the last century, just twice in 30 years, the forces of empire and intolerance and extreme nationalism consumed this continent and cities like this one were largely reduced to rubble," Obama said.
While admitting there could be frustrations with European institutions, he argued that "turning inward" was not the answer to Europe's problems.
As rightwing populism gains ground in parts of the continent in response to growing Islamic radicalism, he urged Europe to remain open.
"I want you to remember that our countries are stronger, they're more secure and more successful when we integrate people of all backgrounds and faiths, and make them feel as one. And that includes our fellow citizens who are Muslim," he said.
On a visit to Britain ahead of his arrival in Germany, the US president had also waded into an increasingly-bitter debate over the UK's membership in the European Union, urging Britons to vote against leaving the bloc in a June referendum.
In a mark of that frustration, Obama bluntly told his audience that Europe needs to do more to shoulder the collective security burden.