United States President Donald Trump has made his first visit to soldiers stationed in a troubled region, flying in to Iraq on Boxing Day in an unannounced trip.

Key points: Mr Trump had been criticised for not yet visiting overseas troops

Mr Trump had been criticised for not yet visiting overseas troops He had said he did not see such a trip as "overly necessary"

He had said he did not see such a trip as "overly necessary" The US Government remains partially shut down amid a funding stalemate over a border wall

It comes a week after Mr Trump stunned his national security advisers by announcing he would withdraw US troops from neighbouring Syria where they have been fighting Islamic State (IS) militants.

Defence Secretary Jim Mattis abruptly resigned following the announcement, and Mr Trump's decision rattled allies around the world, including in Iraq.

The President travelled with first lady Melania Trump and their trip was shrouded in secrecy.

Air Force One flew overnight from Washington, landing at an airbase west of Baghdad under the cover of darkness on Wednesday evening (local time).

White House press secretary Sarah Huckabee Sanders told reporters aboard Air Force One that Iraq's Prime Minister Adil Abdul-Mahdi accepted an invitation from Mr Trump to visit the White House.

The two leaders spoke by phone. They did not meet when Mr Trump was in Iraq.

Mr Trump had faced criticism for not visiting overseas troops. ( AP: Andrew Harnik )

As their plane was refuelled on the way back to the US, the President and first lady stopped in Germany in a second unannounced visit, where they greeted US troops stationed in the country's Ramstein Air Force base.

Mr Trump made his way down a rope line at the military base, shaking hands, chatting and posing for photos.

Fifteen years after the 2003 invasion, the US still has more than 5,000 troops in Iraq as the fight against remaining pockets of resistance by the Islamic State (IS) group continues.

IS has lost a significant amount of territory in Iraq and Syria but is still seen as a threat.

Mr Trump said he wanted US soldiers home from Syria and that Iraq could still be used as a base to stage attacks on IS militants if needed.

He told reporters travelling with him that if needed, the US can attack IS "so fast and so hard" that they "won't know what the hell happened".

Mr Trump, who speaks often about his support for the US military, had faced criticism for not yet visiting troops as he comes up on his two-year mark in office.

The unannounced trip comes as the US government remains partially shut. ( AP: Andrew Harnik )

In an interview in October he said he "will do that at some point, but I don't think it's overly necessary".

He later began to signal that such a visit was in the offing.

Mr Trump had planned to spend Christmas at his private club in Florida, but stayed in Washington due to the shutdown.

It is unclear whether his trip to Iraq was added after it became apparent that the government would be shut down indefinitely due to a stalemate between over the President's demand for a wall along the US-Mexico border.

Mr Trump's Middle East policy is in flux

Mr Trump went against the views of his top national security advisers in announcing the Syria withdrawal, a decision that risks creating a vacuum for extremists to thrive.

There are dire implications in particular for neighbouring Iraq.

The Iraqi Government now has control of all of its cities, towns and villages after fighting its last urban battles against IS in December 2017.

But its political, military and economic situation remains uncertain, and the country continues to experience sporadic bombings, kidnappings and assassinations, which most people attribute to IS.

Iraqi Prime Minister Adel Abdul-Mahdi recently said Iraqi troops could deploy into Syria to protect Iraq from threats across its borders.

Iraq keeps reinforcements along its frontier to guard against infiltration by IS militants, who hold a pocket of territory along the Euphrates River.

Donald and Melania Trump meet with government and military advisers at Al Asad Air Base. ( AP: Andrew Harnik )

Two of Mr Trump's recent predecessors visited Iraq early in their terms.

President George W Bush visited Iraq in November 2003, about eight months after that conflict began.

Barack Obama visited Iraq in April 2009, the first year of his eight years in office, as part of an overseas tour.

Vice-President Mike Pence visited Afghanistan in December 2017, not long after Mr Trump outlined a strategy to break the stalemate in America's longest war.

AP