U.S. President Donald Trump made a surprise visit to U.S. troops in Iraq on Wednesday, his first trip to a conflict zone nearly two years into his presidency and days after announcing a pullout of American troops from neighbouring Syria.

Air Force One touched down at the Al Asad Air Base west of Baghdad after an overnight flight from Washington with his wife Melania Trump, a small group of aides and Secret Service agents, and a pool of reporters. He was expected to stay for around three hours.

Trump has drawn fire from some in the U.S. military for not having visited U.S. troops in conflict zones since taking office in January 2017, particularly after he cancelled a trip to a First World War cemetery in France last month due to rain.

While there has been no full-scale violence in Iraq since ISIS suffered a series of defeats last year, U.S. troops train and advise Iraqi forces still waging a campaign against the militant group.

On his way home from Iraq, he will also stop to visit troops at Ramstein Air Base in Germany.

Trump was looking for some positive headlines after days of turmoil over his decisions to withdraw all U.S. troops from Syria, pull out half of the 14,000-strong contingent in Afghanistan, and push out Defence Secretary James Mattis two months earlier than planned for criticizing his policies.

Trump and his wife Melania Trump greet military personnel at the dining facility in Al Asad Air Base. (Jonathan Ernst/Reuters)

Many Republican and Democratic lawmakers have heaped scorn on Trump for his sudden order last week to withdraw from Syria.

On his stop in Iraq, he defended his decision to pull out the 2,000 troops from Syria, which he has said was made possible by the defeat of Islamic State in Iraq and Syria militants.

"We want peace, and the best way to have peace is through strength," Trump told troops wearing camouflage fatigues in a hangar as he concluded his visit. He said some troops "can now return home to their families."

Trump, flanked by national security adviser John Bolton, meets political and military leaders at Al Asad Air Base. (Jonathan Ernst/Reuters)

"Our presence in Syria was not open ended and it was never intended to be permanent," he said.

Trump's critics have said the fight is far from over and the withdrawal leaves allies in the lurch.

One of those critics was Mattis, who said in a candid resignation letter last week that his views did not align with the president's, particularly in regard to the treatment of U.S. allies. Mattis had planned to leave at the end of February, but Trump forced him to go on Jan. 1 after his resignation letter.

Trump's uneven relationship with troops

Trump has also faced negative headlines for wanting to pull troops from Afghanistan, where they have been since 2001. Trump has questioned how long troops there should have to remain in what has become America's longest war.

Trump's unannounced visit to Iraq followed in the footsteps of two of his predecessors, Republican George W. Bush and Democrat Barack Obama, who both made surprise trips to see troops.

The U.S. military says it has about 5,200 troops in Iraq, focused on training and advising Iraqi troops to ensure that ISIS does not re-emerge.

Watch: U.S. begins pulling troops out of Syria as Trump claims victory over ISIS

U.S. President Trump has begun what will be a total withdrawal of U.S. troops from Syria, declaring on Wednesday they have succeeded in their mission to defeat Islamic State and were no longer needed in the country. 2:39

NATO defence ministers agreed in February to a bigger "train-and-advise" mission in Iraq after a U.S. call for the alliance to help stabilize the country after three years of war against ISIS.

Trump has had an uneven relationship with America's military. He did not have to serve during the Vietnam War after being diagnosed with bone spurs in his heels.

As president-elect, Trump was drawn to the brawn of the armed forces and stacked his first cabinet with generals, many of whom have since left his administration.

Trump has also wanted to end protracted U.S. involvement in overseas conflicts, and to force allies to pay more for the costs that he says fall disproportionately on American taxpayers.

No plans for Iraq pullout

In Iraq, he said, countries in the region will have to pick up the burden, but he has no plans for a withdrawal from that country.

"These people are going to have to start doing a lot of their own work and they're going to have to start paying for it because the United States cannot continue to be the policeman of the world," Trump told reporters.

Trump also spoke to troops gathered in a dining hall festooned with holiday decorations and teased soldiers about their favourite football teams.

To reporters, he lamented the wear and tear of overseas conflicts.

"It's time to get our young people out," Trump said. "And I've been signing plenty of letters and I don't like sending those letters home to parents saying that your young man or your young woman has been killed.

"I don't like doing it. We've been doing it long enough."