President Donald Trump Wednesday ordered construction of a wall along the country's southern border with Mexico to thwart illegal migration while threatening to pull some funds from hundreds of so-called U.S. sanctuary cities.

Trump signed the immigration executive orders as he visited the Department of Homeland Security, the federal agency charged with protecting the U.S. border.

Trump Signs Immigration Orders to Build Mexico Wall

"We are in the middle of a crisis on our southern border. The unprecedented surge of illegal migrants from Central America is harming both Mexico and the United States," he said. "And I believe the steps we will take, starting right now, will improve the safety in both of our countries. It is going to be very, very good for Mexico."

Trump Signs Immigration Orders to Build Mexico Wall

The orders served as an exclamation point to one of the major forces behind Trump's lengthy run to a four-year term in the White House -- his contention that illegal migrants in the U.S. threaten its security and cost American workers their jobs. At rally after rally during his campaign, his most fervent cheering supporters shouted, "Build that wall!"

Trump Signs Immigration Orders to Build Mexico Wall

Trump told ABC News that construction of the wall would start within months and continued to contend that Mexico would pay for it, although Mexico has repeatedly said it would not.

Sorry, but your browser cannot support embedded video of this type, you can to view it offline.

Trump said the payment would perhaps be in a "complicated form," signaling it would not be a direct payment from Mexico City to Washington.

The newspaper says money raised by a possible tax on Mexican imports could be used to pay for it.

Republican House Speaker Paul Ryan of Wisconsin praised the actions in a statement.

"This is about keeping Americans safe. We are committed to working with the administration to stop the influx of illegal immigration along the southern border, protect our homeland, and uphold the rule of law. I applaud President Trump for keeping his promise to make this a national priority," Ryan said.

The executive order was not applauded by some, however. Democratic Senator Robert Menendez of New Jersey condemned it in strong terms.

“This is a terrible and ugly decision by a president who is more concerned with right-wing fringe movements than doing what’s right for all of America, for the economy, and for the future of this country," Menendez said. "Donald Trump started his campaign by calling Mexicans rapists and murderers, and he is shamefully starting his presidency by declaring open season on immigrants and refugees, and making taxpayers foot the bill for his nativist impulses."

A senator from the Mexican opposition, Armando Rios Piter, calls the wall a "hostile act" toward the Mexican people. He is urging President Enrique Pena Nieto to cancel next week's meeting with Trump.

Late Wednesday, Pena Nieto said he "regrets and dispproves" of Trump's push to build a wall. He also said he "considering" cancelling next week's visit to Washington.

White House spokesman Sean Spicer said the U.S. would build more detention facilities along the border to house migrants who cross into the U.S. and then give them a "one-way ticket back to the country of their origin."

Spicer said the Trump administration would end what he called the "dangerous catch and release program" border agents currently employ. Migrants are let go after promising to appear in court. Many of them ignore the promise.

Officials say Trump is also considering a four-month freeze on all refugee admissions into the U.S., as well as a ban for at least 30 days for entry to the U.S. by anyone from Iraq, Iran, Libya, Syria, Somalia, Sudan and Yemen — all Muslim majority countries.

The ban could also include an exception for people who are religious minorities in their country and facing persecution.

The office of the U.N. High Commissioner for Refugees said it was aware of the U.S.-Mexican border issue and would "closely follow the impact" of any wall-building program on people seeking refuge in the United States.

"At a time of enormous needs for the protection of refugees," a UNHCR statement said, "we hope that the U.S. will continue its strong leadership role and long tradition of protecting those who are fleeing conflict and persecution."

Trump often used his campaign rallies to criticize U.S. admissions of refugees, employing the phrase, "We have no idea who these people are." He also initially proposed a ban on admitting people from Muslim countries, drawing sharp criticism. He later amended his stance to include countries with links to terrorism.