"The fall of the Berlin Wall brought new hope. But that very closeness has given rise to new dangers," he said in the 28-minute speech. "No one nation, no matter how large or powerful, can defeat such challenges alone." (See the accompanying CNBC video for more.)
Obama has urged a shift in focus from Iraq to Afghanistan, where stability is threatened by a fierce Taliban insurgency.
Germany has roughly 3,500 troops in Afghanistan and is expected to raise that by 1,000 later this year.
But Chancellor Angela Merkel has resisted pressure from the United States to send German soldiers to the more dangerous south of the country and said on the eve of Obama's visit that Germany had "limits" in what it could do.
Obama urged Europe and the United States needed to stand together to send Iran a message that it must abandon its nuclear ambitions and urged both sides to move beyond their differences over the Iraq war to help suffering Iraqis rebuild their lives.
"Yes, there have been differences between America and Europe. No doubt, there will be differences in the future," he said. "The greatest danger of all is to allow new walls to divide us from one another."
His comments were cheered by a huge crowd, some wearing Obama badges, "Yes We Can" t-shirts echoing a slogan of his and carrying American flags.
A reggae band played in the background and people sipped beer under sunny skies in a summertime party atmosphere.
There was loud applause when Obama talked about the environment, multilateralism and human rights, but none when he raised Afghanistan.
"Relations between Germany and the United States will improve under Obama," said Dennis Buchner, 31. "But he also has high expectations on the Germans increasing their military engagement in Afghanistan. That will certainly spark debate in Germany."