HANNOVER, Germany - President Barack Obama delivered a strong defense of international trade deals Sunday in the face of domestic and foreign opposition, saying it's "indisputable" that such agreements strengthen the economies and make U.S. businesses more competitive worldwide.

Obama, on a farewell visit to Germany as president, is trying to counter public skepticism about a trans-Atlantic trade deal with Europe, while also facing down criticism from the 2016 presidential candidates of a pending Asia-Pacific trade pact.

Despite all that, Obama said, "the majority of people still favor trade. They still recognize, on balance, that it's a good idea."

Get Breaking News Delivered to Your Inbox

"It is indisputable that it has made our economy stronger," Obama said about international trade. He said he was confident the trans-Atlantic trade deal could be completed by the end of year, to be presented for ratification. Obama said that once the U.S. presidential election is over and politics settle down, the trans-Pacific pact can "start moving forward."

Obama, at a news conference with German Chancellor Angela Merkel, said the leaders had discussed economic and security issues facing Europe. He credited Germany for being a strong partner on efforts to counter the Islamic State of Iraq and Syria (ISIS) and to provide humanitarian relief to refugees fleeing the fighting in Syria.

But he reiterated U.S. opposition to the idea of establishing a "safe zone" in Syrian territory, a suggestions Merkel has made, because of it would be impractical to put in place.

"As a practical matter, sadly, it is very difficult to see how it would operate short of us essentially being willing to militarily take over a chunk of that country," he said.

Obama spoke after Merkel rolled out the red carpet for him at Hannover's Herrenhausen Palace, a rebuilt version of the former summer royal residence destroyed in World War II. After reviewing German troops in a palace garden, they climbed a spiral staircase and stepped inside for private talks.

Obama made a point to give a public show of support for Merkel's "courageous" handling of the migrant issue.

Merkel, he said, "is on the right side of history on this."

Her decision to allow the resettlement in her country of thousands fleeing violence in Syria and other Mideast conflict zones created an angry domestic backlash. Merkel recently helped European countries reach a deal with Turkey to ease the flow, but she and the other leaders are now under pressure to revisit it.

Obama has a tough sell to make for the trade deal known as TTIP, particularly in Germany. He was joining Merkel later Sunday to open the Hannover Messe, the world's largest industrial technology trade fair, and promote the agreement.

Thousands of people took to the streets in protest in Hannover on Saturday, before Obama arrived. Some carried placards that said "Yes We Can - Stop TTIP!" It was a riff on Obama's 2008 presidential campaign slogan.

In November, more than 100,000 people in Berlin protested against the proposed pact.

Proponents say the deal would boost business at a time of global economic uncertainty. Critics fear the erosion of consumer protections and environmental standards.

Negotiators in Washington and Europe are trying to finalize key parts of the deal before the end of the year, after which Obama's successor and election campaigns in major European countries could further complicate the already difficult negotiations.

Obama said it was important to conclude negotiations even though ratification would be unlikely before he leaves office. "But if we have that deal, then the next president can pick that up rapidly and get that done," he told the BBC in an interview broadcast Sunday.

It's not certain that the next president would pick up where Obama leaves off on the trade deal. The pact has not been a top issue in the campaign to choose Obama's successor. Both leading candidates - Democrat Hillary Clinton and Republican Donald Trump - oppose the Asia-Pacific trade pact for its potential impact on American jobs and wages.

On Monday, Obama was joining Merkel to tour the trade show and giving a speech on challenges facing the U.S. and Europe.

Merkel also used the occasion of Obama's visit to invite the leaders of France, Britain and Italy to Hannover for a meeting Monday to discuss Syria, Libya, ISIS, migration and other issues.