WASHINGTON — Congressional Republicans, already facing a difficult election landscape, confronted a prospect on Sunday they had worked feverishly to avoid: a threat by President Trump to shut down the government over funding for a border wall.
“I would be willing to ‘shut down’ government if the Democrats do not give us the votes for Border Security, which includes the Wall!” Mr. Trump wrote on Twitter. “Must get rid of Lottery, Catch & Release etc. and finally go to system of Immigration based on MERIT! We need great people coming into our Country!”
Last week, Republican leaders thought they had reached a deal with Mr. Trump to delay a confrontation on funding for the wall until after the November midterm elections, according to a person familiar with their discussion.
But Mr. Trump’s shutdown threat, in which he also demanded several pieces of a comprehensive immigration overhaul that is stalled in Congress, has opened the door to a politically bruising spending fight as the fiscal year ends in September.
With the election coming just weeks later, the party can ill afford a disruption that voters — already disgusted by Washington dysfunction — may hold the president accountable for.
A shutdown would also distract from Senate Republicans’ main business in September: their push to confirm Judge Brett M. Kavanaugh to the Supreme Court.
“We’re going to have a challenging midterm anyway, and I don’t see how putting the attention on shutting down the government when you control the government is going to help you,” Representative Tom Cole, Republican of Oklahoma, said in an interview.
Representative Steve Stivers of Ohio, the chairman of the committee charged with electing Republicans to the House, insisted that a shutdown was unlikely.
“I don’t think we’re going to shut down the government,” Mr. Stivers said on the ABC News program “This Week.” “You know, I think we’re going to make sure we keep the government open, but we’re going to get better policies on immigration.”
Democrats and Republicans have in fact made unusual progress on the 12 appropriations measures necessary to keep the government operating. Current funding for the government expires Sept. 30.
Mr. Trump’s shutdown threat on Sunday was part of a flurry of tweets in which he attacked favorite targets like the “Robert Mueller Rigged Witch Hunt” (“an illegal Scam!”) and the news media (“driven insane by their Trump Derangement Syndrome”).
From the very beginning of his term, Mr. Trump has seemed to court a shutdown over the wall, despite the deep objections of much of his staff and Republicans in Congress. Each time congressional leaders have reached a broad bipartisan agreement on spending, he has expressed anger that it does not include money for the wall and threatened to torpedo the deal.
He tweeted in the spring of 2017 that perhaps what the country needed was a “good shutdown” over that issue, among others. The Twitter post set off a scramble at the White House, where the president’s aides had been trying to portray a new comprehensive spending deal as a victory.
Then, earlier this year, as Congress approved a catchall spending bill that had no wall funding, Mr. Trump briefly threatened a veto before signing it. But he said he would never sign such an omnibus bill again. His base was enraged at the time, with some core supporters saying Mr. Trump had essentially ceded the midterm elections by failing to insist on the wall funding.
Republican leaders met with the president last week at the White House to talk about funding for the federal government. They emerged thinking they had a deal to delay the wall funding debate, and Senator Mitch McConnell of Kentucky, the Republican leader, suggested as much on Friday in a radio interview on WHAS in Louisville.
When asked if the inevitable battle between Republicans and Democrats over the wall would wait until after the midterm elections, Mr. McConnell said, “Probably, and that’s something we do have a disagreement on.”
Asked if he feared a government shutdown, Mr. McConnell was emphatic. “No, that’s not going to happen,” he said.
The House speaker, Paul D. Ryan of Wisconsin, said Mr. Trump was willing to wait for his wall funding. “As far as the wall is concerned, we’ve gotten some wall funding already underway,” he told reporters on Thursday before the House left for its August recess.
“I think it’s not a question of if, it’s a question of when,” he added. “And the president’s willing to be patient to make sure that we get what we need so that we can get that done, because border security’s extremely important.”
Mr. Trump campaigned on a vow to build a “big, beautiful wall” at the nation’s southern border, and 19 months into his presidency, he is clearly frustrated at the lack of movement on his signature issue. Congress passed a measure in March that included $1.6 billion for more than 90 miles of barriers along the border with Mexico, but that sum is far short of the $25 billion the president would need to fulfill his campaign promise.
In his tweet on Sunday, Mr. Trump spotlighted Congress’s failure to address one of the most intractable issues in Washington: immigration policy. The president has long demanded legislation that would include the White House’s “four pillars”: a path to citizenship for the young unauthorized immigrants known as Dreamers; an end to the so-called visa lottery, which aims to bring people from underrepresented nations to the United States; deep cuts in legal immigration; and funding for the wall.
Both the House and the Senate rejected immigration bills this year that included the president’s four pillars. The Senate measure failed by a wide margin — an outcome that a spokesman for the Democratic leader, Senator Chuck Schumer of New York, recalled on Sunday in an acid response to the president’s tweet.
“The bill he’s describing only got 39 votes in the Senate floor,” said the spokesman, Matt House. “He should learn from his mistakes.”
A spokesman for Representative Nancy Pelosi of California, the House Democratic leader, was equally caustic. “President Trump should stay on the golf course and stay out of the appropriations process,” said the spokesman, Drew Hammill. “Democrats are committed to keeping government open.”
Mr. McConnell shares that commitment. He said in the radio interview that the Senate was “on the way to passing at least nine of the 12” spending bills needed to keep the government open, and would probably wrap the remaining measures into a small catchall bill known as a “minibus.”
He even gave credit to Mr. Schumer and the Democrats, noting that the two parties “reached an agreement earlier this year about how much we are going to spend, this year and next year, and we’re sticking to it and have had a very cooperative period here.”
Mr. Ryan said much the same when he addressed reporters on Thursday, noting that unlike in years past, lawmakers have “a very good chance” of getting the majority of their appropriations bills done by the end of September.
“We walked the president through our strategy for appropriations before the fiscal year,” Mr. Ryan said. “He agreed with our strategy. So we think we have a unified strategy to make sure that we can get as many appropriation bills done as possible.”
Julie Hirschfeld Davis contributed reporting.
Follow Sheryl Gay Stolberg on Twitter: @SherylNYT.