ATHENS (Reuters) - Barack Obama offered solidarity with Greece over its debt and migrant crises on Tuesday during his final trip to Europe as U.S. president before handing over power to Donald Trump.

Obama delighted his Greek hosts by supporting debt relief for the recession-battered country, which has seen its economy shrink by a quarter in just seven years, but riot police had to use teargas to quell anti-U.S. protesters in central Athens.

Greece hopes Obama will be able to persuade its foreign creditors to restructure some of its debt, which stands at nearly 180 percent of national output.

“We cannot simply look to austerity as a strategy,” Obama said after talks with Greek Prime Minister Alexis Tsipras.

“Our argument has always been that when the economy contracted this fast, when unemployment is this high, that there also has to be a growth agenda to go with it and it is very difficult to imagine the kind of growth strategy that’s needed without some debt relief mechanism,” Obama said.

Athens signed up to a third economic bailout package of up to 86 billion euros ($93 billion) in mid-2015 but says it needs a long-term debt restructuring to exit the crisis - a message repeated on Tuesday by Tsipras, a leftist whose popularity is waning.

Obama, who said the United States would stand “shoulder to shoulder” with Greece, a NATO ally, was due to visit Germany on Wednesday, the main champion of economic austerity in Europe.

Slideshow ( 12 images )

“YANKEES GO HOME!”

Leftist groups are angry that Obama, the first U.S. leader to visit Athens since Bill Clinton in 1999, is visiting just two days before the anniversary of a bloody 1973 student revolt that helped topple a Greek military junta backed by Washington.

The clashes, just a few km (miles) from where Greek leaders were hosting Obama at a state dinner, erupted after about 7,000 people, some of them hooded, marched through central Athens and tried to reach the parliament and the U.S. embassy.

The protesters waved banners that read: “We don’t need protectors!” and “Yankees go home!”

As well as its economic travails, Greece, a country of 11 million, has been grappling with a migrant crisis engulfing Europe. More than 60,000 people are stranded in Greece after their onwards journey into Europe was sealed off this year as borders were shut in the Balkans.

“It is important that we don’t have any single country bear the entire burden of these challenges,” Obama said.

Slideshow ( 12 images )

Humanitarian organisations have called on Obama to press the need for a European response to the problem and to demand wealthier countries take in a bigger share of refugees.

Obama, who is in Athens until Wednesday afternoon, was staying at a luxury seaside resort on a peninsula south of Athens, less than 15 km (9 miles) from a disused airport that is temporarily housing hundreds of migrants and refugees.

Children played outside the abandoned terminal through washing lines strung with laundry. Some sat on a battered old sofa as Obama’s motorcade sped past them.

“We want Obama to come and see us here, how we are living like prisoners,” said Hatzi Naser, 42, from Afghanistan, still mired in conflict more than a decade after U.S. forces ousted the Taliban following the 9/11 attacks on the United States.

“He is the reason we are here, because of his army’s war. We want him to come and see the filth we are living in.”