AL ASAD AIR BASE, Iraq (Reuters) - President Donald Trump said on Wednesday he is prepared to wait as long as it takes to get $5 billion from taxpayers for his U.S.-Mexico border wall, a demand that has triggered a partial shutdown of the federal government that is now in its fifth day.

With no immediate end to the shutdown in sight, Trump made his remarks during a surprise visit to Iraq and blamed the shutdown on Democrat Nancy Pelosi, who was expected to become speaker of the U.S. House of Representatives on Jan. 3.

Trump had previously said he was prepared for a lengthy shutdown and when asked on Wednesday how long he would wait to get what he wants, he said, “Whatever it takes.”

“Nancy is calling the shots,” said the Republican president, suggesting that her opposition to his demand for wall funding had to do with Pelosi’s need for votes to become speaker.

Pelosi largely locked up the speakership weeks ago.

“The American public is demanding a wall,” Trump said while on the ground at Al Asad Air Base in Iraq.

During a televised Dec. 11 meeting with Pelosi and Senate Democratic leader Chuck Schumer, Trump had said he would be “proud to shut down the government for border security” but has since shifted the blame to Democrats.

During his 2016 presidential campaign, Trump repeatedly promised Mexico would pay for his proposed wall. After Mexico repeatedly refused to do so, he began seeking U.S. taxpayer funding for the wall, which he sees as vital to controlling illegal immigration.

A Reuters/Ipsos poll in late November found that improved border security was a top-three priority for only about 31 percent of Americans surveyed.

Even with both chambers of Congress and the White House under Republican control for the past two years, former real estate developer Trump has not gained full funding for his wall.

Democrats and some Republicans view it as a costly, unneeded and ineffective project, but some Republicans support the idea and back Trump’s demand for $5 billion in partial funding.

“His resolve is very firm,” Representative Mark Meadows, a conservative Republican, told CNN.

Following weeks of failed talks between Trump and congressional leaders, parts of the U.S. government shut down on Saturday, affecting about 800,000 employees of the Departments of Homeland Security, Transportation and other agencies.

Most of the federal government, which directly employs almost 4 million people, is unaffected. The Defense Department and other key agencies are fully funded through Sept. 30.

Congress was scheduled to reconvene after a holiday break on Thursday and resume debate on the matter.