WASHINGTON—President Trump told Democratic leaders Tuesday he would be proud to shut down the U.S. government later this month if Congress doesn’t meet his demand to fund construction of a wall on the Mexico border, escalating a standoff over spending in an unusual public spectacle in the Oval Office.

In a move lawmakers and aides said would undermine Republican intentions to blame a partial shutdown on Democrats, Mr. Trump said he would shutter swaths of the government if Democrats refuse to include $5 billion in wall funding in any year-end spending package.

A physical wall along the U.S.-Mexico border is a central element of Mr. Trump’s agenda and a rallying cry for his core supporters. With Democrats unified in opposition to the wall, it has emerged as the single major sticking-point in the current spending showdown. Seven spending bills expire at 12:01 a.m. on Dec. 22, including one funding the Homeland Security Department, which oversees the border.

“I am proud to shut down the government for border security,” Mr. Trump told Senate Minority Leader Chuck Schumer (D., N.Y.) and House Minority Leader Nancy Pelosi (D., Calif.) in an Oval Office conference that the Democrats had been told would be private. “I will take the mantle. I will be the one to shut it down.”

Mr. Trump’s comments altered the political dynamics around the potential partial shutdown. Republicans who had been positioning to blame a shutdown on Democrats said such an argument would now be more difficult to make.

“Everybody wants to blame it on the other party, always,” said Sen. Jeff Flake (R., Ariz.), a frequent critic of Mr. Trump. “That’s out the window now.”

Vice President Mike Pence, who looked on silently during the public portion of the Oval Office discussion, later met with Senate Republicans at their weekly lunch Tuesday, but said little, lawmakers said. Diverging from Mr. Trump, Senate GOP leaders said after the meeting that they had no desire to shutter the government.

“No matter who precipitates a government shutdown, the American people don’t like it. I hope that will be avoided,” said Senate Majority Leader Mitch McConnell (R., Ky.).

Some Republicans applauded Mr. Trump’s stance on Tuesday. “I’m going to stand by President Trump. He needs to dig in and not give in,” said Sen. Lindsey Graham (R., S.C.), a member of the Appropriations Committee, which handles spending bills. “Let’s take this to the public and see what happens.”

Democrats condemned—and also celebrated—Mr. Trump’s position.

“No president should ever say he would be proud to shut the government down,” Mr. Schumer told reporters on Tuesday.

But Mrs. Pelosi told a group of House Democrats it was “an accomplishment” that Democrats “did get him to say, to fully own, that the shutdown was his,” according to an aide in the room. Mrs. Pelosi also told lawmakers that Mr. Trump’s commitment to secure wall funding was “like a manhood thing for him,” the aide in the room said.

Mr. Schumer and Mrs. Pelosi said they proposed to Mr. Trump two options: Congress could pass the six less-controversial spending bills and extend current Homeland Security funding through next September, or extend current funding for all seven bills.

Both Mrs. Pelosi and Mr. Schumer said Mr. Trump told them he would think about their two proposals. Lawmakers from both parties are usually willing to support stop-gap spending bills to avoid a shutdown.

Mrs. Pelosi, House Democrats’ nominee for speaker, is still working to secure enough votes to win the contest on the House floor next month. Some House Democrats, including members of the Congressional Hispanic Caucus, have said they could oppose her if she cedes too much to Mr. Trump in the border wall talks.

Mr. Trump alluded to that dynamic in the meeting. “I also know that, you know, Nancy is in a situation where it’s not easy for her to talk right now, and I understand that,” Mr. Trump said in the Oval Office.

“Please don’t characterize the strength that I bring to this meeting as the leader of the House Democrats who just won a big victory,” Mrs. Pelosi shot back.

The Democratic leaders also tangled repeatedly over whether House Republicans, who hold the majority for the rest of the calendar year, had enough votes to pass a spending bill that included Mr. Trump’s $5 billion in wall funding.

House Republicans included $5 billion for the border wall in their fiscal 2019 Homeland Security spending bill, but the full House hasn’t voted on that bill, suggesting House GOP leaders lack support to pass it.

Typically, House Republicans try to pass legislation marking their own negotiating position, even if it stands no chance of passing the Senate. Most bills need 60 votes to clear procedural hurdles in the Senate, where Republicans currently hold 51 seats.

But on Tuesday, House Speaker Paul Ryan (R., Wis.) said the House didn’t want to vote on something that couldn’t clear the Senate. “We want to pass what the Senate can pass and the president supports, but as you know this takes 60 votes,” Mr. Ryan said.

Newsletter Sign-up The 10-Point. A personal, guided tour to the best scoops and stories every day in The Wall Street Journal. PREVIEW

House Republicans are considering trying to pass a short-term spending patch that would include funding for the border wall, according to aides. But even if it passes the House, where it would face opposition from Democrats and potentially from centrist Republicans, it would be unlikely to advance in the Senate.

In the meeting with Democrats Tuesday, Mr. Trump claimed that “a lot of the wall has been built” and that “some wall has been reinforced by our military.”

Customs and Border Protection has overseen construction of multiple stretches of fencing since Mr. Trump took office. But many of those projects either replaced old, dilapidated steel panels that border agents couldn’t see through or were started under the Obama administration. Most of the military work at the border fence has been limited to laying miles of concertina wire along the base of the fence or along the top in some areas.

—Alicia Caldwell, Natalie Andrews and Joshua Jamerson contributed to this article.

Write to Kristina Peterson at kristina.peterson@wsj.com and Vivian Salama at vivian.salama@wsj.com