WASHINGTON — President Trump's threat to shut down the federal government unless Congress funds his controversial border wall could end up hurting Republicans, prompting GOP leaders to try to avert the politically damaging action.

"Trump is the one who has threatened a shutdown, so he's the one who'll get the blame — except from his hard-core base," said Jack Pitney, a politics professor at Claremont McKenna College in California. "And he'll hurt even the more sensible Republicans in Congress since they're in charge and will get the blame along with him."

Congressional leaders say Trump is sparking an unnecessary and probably unwinnable battle with the Senate, where Democrats have vowed to block money for what their leaders denounce as an "ineffective, immoral and expensive" barrier.

"I don't think a government shutdown is necessary and I don't think most people want to see a government shutdown, ourselves included," House Speaker Paul Ryan, R-Wis., told reporters after a speech on tax reform in Oregon this week.

Trump on Tuesday promised a crowd of supporters in Phoenix: "If we have to close down our government, we're building that wall."

The president made it clear that he will blame "obstructionist Democrats" for a government shutdown, but Democrats say he's the one pushing the unpopular idea.

"If the President pursues this path, against the wishes of both Republicans and Democrats, as well as the majority of the American people, he will be heading towards a government shutdown which nobody will like and which won’t accomplish anything," said Senate Minority Leader Chuck Schumer, D-N.Y.

House Minority Leader Nancy Pelosi, D-Calif., said the last government shutdown, in 2013, cost the U.S. economy $24 million, according to an estimate from Standard & Poor's financial services company.

"With a Republican House, Senate and Administration, Republicans have absolutely no excuses for threatening America’s families with a destructive and pointless government shutdown," Pelosi said.

Funding deal: Spending bill excludes border wall, but Trump declares victory anyway

Border wall:Trump waives environmental laws to speed construction

More coverage: House GOP passes $788B bill for Pentagon, border wall

Trump made the same threat during a funding battle in April but backed down when Congress passed a last-minute deal that included money for stepped-up border security but no funds to build a wall. That deal kept the government running through September.

Funding for federal agencies will run out on Oct. 1, when a new fiscal year begins, unless Congress approves a spending package and Trump signs it into law.

The House has already passed legislation that included $1.6 billion for construction of 74 miles of wall along the 2,000-mile border between the U.S. and Mexico. But Democrats, whose votes are needed to pass spending bills in the closely divided Senate, oppose any measure that includes money for the wall.

"Democrats have no reason to fold," Pitney said. "Trump has already essentially taken the blame for whatever happens by proclaiming that he's ready to shut down the government. And the border wall is utterly toxic among Democratic voters, so there's no reason for Democrats in Congress to give an inch."

The border wall was a key campaign promise for Trump, whose campaign rallies often erupted with shouts of "Build the Wall" — a chant that broke out again in Phoenix on Tuesday.

However, Trump promised that he would make the Mexican government pay for the barrier. Mexican officials have steadfastly refused to do that, forcing the president to turn to Congress for funding. The president has said he will get Mexico to reimburse U.S. taxpayers for the cost, but it's not clear exactly how he would do that.

The Department of Homeland Security has estimated that the total cost of the border wall would be about $22 billion. A report by the Democratic staff of the Senate Homeland Security and Governmental Affairs Committee has estimated the cost at closer to $70 billion, not including the annual cost of maintenance.

Ryan predicted that Congress will likely have to pass a stop-gap bill to keep the government funded for a few more weeks or months while lawmakers negotiate a longer-term deal to last through September 2018. If that's the case, the showdown over the wall may be pushed off for a short while.

"I don't think anyone's interested in having a shutdown," Ryan said in Oregon. "I don't think it's in our interest to do so while we work on doing what we actually said we would do, what we've done already in the House and we need to do, which is to control our borders."