WASHINGTON/NEW YORK (Reuters) - President Donald Trump’s fellow Republicans rebuked him on Wednesday after his threat to shut down the U.S. government over funding for a border wall rattled markets and cast a shadow over congressional efforts to raise the country’s debt ceiling and pass spending bills.

“I don’t think anyone’s interested in having a shutdown,” the top Republican in Congress, House of Representatives Speaker Paul Ryan, told reporters on Wednesday in Hillsboro, Oregon, where he visited an Intel factory.

Ryan said building a wall along the country’s border with Mexico to deter illegal immigration was necessary, but added that the government did not have to choose between border security and shuttering operations.

Trump in a speech on Tuesday evening threatened a shutdown if Congress does not agree to fund constructing the wall, a signature promise of his presidential campaign, which added a new complication to Republicans’ months-long struggle to reach a budget deal.

After Mexico rejected a chief part of Trump’s promise - that it would pay for the wall - the president said the United States would fund it initially and be repaid by its southern neighbor. Lawmakers, including many Republicans, have not made that funding a top priority, as some question if a wall is necessary.

Congress will have about 12 working days when it returns on Sept. 5 from its summer break to approve spending measures to keep the government open, while also facing a looming deadline to raise the cap on the amount the government may borrow. Both are must-approve measures.

U.S. stocks and the dollar weakened and investors pivoted to the safety of U.S. Treasury securities on Wednesday after Trump's threat. The S&P 500 Index .SPX closed about 0.3 percent lower, the Dow Jones Industrial Average .DJI was down by 0.4 percent and the Nasdaq Composite Index .IXIC slid 0.3 percent.

Ryan suggested Congress would need to approve a short-term extension, or continuing resolution, of current funding levels so that the Senate could have more time to pass a full spending bill. That would push the budget battle to later in the year and could in turn delay attempts at tax reform, another signature Trump campaign issue.

TENSIONS WITH PARTY LEADERS

Friction between Republicans and Trump has grown in recent months, with the president publicly castigating some party leaders, notably Senate Majority Leader Mitch McConnell, and expressing infuriation that Congress has not passed any significant legislation since his January inauguration.

McConnell did not take a stand on the border wall issue on Wednesday.

He said in a statement he and Trump were in regular contact and working together on a list of goals that included preventing a government default and funding government priorities “in the short and long terms.”

“We have a lot of work ahead of us, and we are committed to advancing our shared agenda together and anyone who suggests otherwise is clearly not part of the conversation,” he said.

A White House statement said Trump would hold “previously scheduled meetings” with McConnell once Congress returns to Washington and that Trump and McConnell “remain united on many shared priorities, including middle class tax relief, strengthening the military, constructing a southern border wall, and other important issues.”

Congress frequently has to pass funding extensions for a few weeks or months while it hammers out a full budget. Occasionally lawmakers have enter a standoff over a single issue, delaying agreement and forcing a shutdown. The most recent closure, which spanned 15 days in October 2013, was over funding for the Affordable Care Act, popularly known as Obamacare.

In opinion polls during and after that shutdown, voters loudly disapproved of the Republican Party, which controlled the House of Representatives at the time.

Representative Tom Cole of Oklahoma, the Republican chairman of a House Appropriations subcommittee, said Trump’s threatened move could backfire on the party.

Slideshow ( 3 images )

“When you control the presidency, the Senate and the House, you’re shutting down the government that you’re running. I don’t think it’s smart politically and I don’t think it would succeed practically,” he told Reuters in an interview.

‘RAN ON IT, WON ON IT’

The White House stressed on Wednesday that Trump would work with Congress to get funding for the wall.

“The president ran on it, won on it and plans to build it,” said White House spokeswoman Natalie Strom.

Slideshow ( 3 images )

The party’s conservative wing backed the president’s call for wall funding, with Representative Jim Jordan of Ohio, a founding member of the Freedom Caucus, telling Reuters any government shutdown would be caused by Senate Democrats.

Representative Adam Kinzinger, a Republican member of the House Foreign Affairs Committee, said, however, the threat was “dangerous for our role in the world as we’re talking to nations like Afghanistan to say: ‘Here’s how you govern yourself.’”

He added it could also hurt financial markets’ confidence in the United States.

“Trump saying he would be willing to shut down the government over the wall obviously doesn’t really inspire much confidence in anyone,” said Michael O’Rourke, chief market strategist at JonesTrading in Greenwich, Connecticut.

The House passed a spending bill late last month that included funding for the wall. Republicans’ slim majority in the Senate means Democrats are needed to pass most legislation and they have opposed including border wall funding in any fiscal 2018 spending bill.

DEBT LIMIT

Congress also must periodically raise the debt limit to keep the U.S. government borrowing and operating. Politicians sometimes take advantage of that need to push through policy or spending changes.

The Treasury Department, already using “extraordinary measures” to remain current on its obligations, has said the debt limit must be raised by Sept. 29. Trump has asked Congress to extend the limit with a “clean” bill that excludes any other provisions.

Credit ratings agency Fitch said on Wednesday it would review the U.S. sovereign debt rating, “with potentially negative implications,” if the debt limit is not raised in a timely manner.