In his first two years in office, President Trump operated without a clear check on his power. With his party controlling both houses of Congress, he issued demands from his bedroom in the form of early-morning tweets, and legislative leaders got in line. He rarely was personally confronted about his untruths and misstatements. And he mostly ignored congressional Democrats, choosing to spar instead with journalists.

That all came to a crashing halt Tuesday. In an extraordinarily heated public fight with the nation’s top two Democratic leaders, the combustible president confronted for the first time the enormity of the challenge he will face over the next two years: divided government.

House Minority Leader Nancy Pelosi (D-Calif.), the likely next speaker, and Senate Minority Leader Charles E. Schumer (D-N.Y.) called out Trump’s falsehoods. They exposed him as malleable about his promised border wall. They lectured him about the legislative process and reiterated to him that he lacked the votes to secure the $5 billion he seeks for the wall.

The Democrats also needled him for his party winning Senate contests last month only in reliably red states. They provoked him by highlighting the softening of the economy and the gyrations in the stock market. And they extracted from him a claim of personal responsibility for the current budget brinkmanship.

“I am proud to shut down the government for border security,” Trump said. “I will take the mantle. I will be the one to shut it down.”

During 17 extraordinary minutes of raised voices, pointed fingers and boorish interruptions in the Oval Office on Tuesday, Pelosi and Schumer introduced Trump to Washington’s new dynamic.

And no apparent progress was made — perhaps a harbinger for what lies ahead.

“Unfortunately, this has spiraled downward,” Pelosi interjected midway through the televised meeting.

Once she returned to the Capitol, the speaker-in-waiting told some of her Democratic colleagues that she felt like she had been in “a tinkle contest with a skunk” — and even questioned the president’s manhood, according to a Democratic aide in the room.

“It’s like a manhood thing for him,” Pelosi said in reference to the wall, according to the aide. “As if manhood could ever be associated with him.”

With Democrats sweeping into power in the House in January, Trump for the first time will be forced to work with the opposition party to govern. And if Tuesday’s spectacle is any indication, Pelosi and Schumer intend to be tough adversaries. They showed an eagerness to challenge the president by using some of his own tactics against him. They tried not only to debate him on policy, but also to hold him accountable for his fact-challenged bluster and to paint him as weak and inept.

“When you feed yourself a diet of adoration and echo chambers, you aren’t well prepared to handle actual pushback,” said Stu Loeser, a New York-based Democratic strategist and former aide to Schumer. “The president came into office bragging that he was the world’s greatest dealmaker, but he is yet to show that to the American people.”

Several White House advisers and GOP congressional aides said they believed Trump damaged himself by agreeing to own a possible shutdown and so vividly saying he would not blame it on Schumer, as he did an earlier shutdown. By doing that, these people said, the president took away his main leverage: The House could pass a $5 billion bill, and Republicans could come along in the Senate.

Still, some Trump allies believed the Tuesday clash with Pelosi and Schumer was a successful contrast for the president. They argued that he directly and repeatedly conveyed his core message that building a wall is essential to securing the nation’s border with Mexico.

“We need border security. People are pouring into our country, including terrorists,” Trump said. He added, “You can’t have very border security without the wall.”

Sen. John Neely Kennedy (R-La.) said of the televised clash: “I didn’t see anybody who was particularly vituperative. I thought it was passion, and that happens all the time around here.”

Kennedy added: “If I were playing poker with President Trump and he was across the table from me and he had demonstrated the face that he demonstrated in that meeting, and I wasn’t holding good cards, I’d fold, because I don’t think he’s bluffing. I think he’s prepared to shut down the government.”

At a closed-door lunch with Senate Republicans, Vice President Pence explained the president’s performance by saying that the Trump the public sees on the stump at campaign rallies is the same Trump fighting in Washington, according to two senators in attendance.

The conflict comes at a fragile moment for Trump’s presidency. The Russia investigation is intensifying and becoming more perilous both politically and perhaps legally. House Democrats are preparing a series of potentially damaging investigations into Trump’s finances and allegations of corruption in the administration. The 2020 presidential campaign is about to begin, starting with an expected free-for-all in the Democratic primaries.

Meanwhile, Trump is scrambling to hire a new chief of staff, having been turned down by his pick for the job after announcing on Saturday that John F. Kelly would be leaving by year’s end.

After the press pool left the Oval Office on Tuesday, Trump repeated to Pelosi and Schumer his claim that many people want to be his chief of staff. Schumer then looked at Kelly, who was standing in the room, and remarked that it appeared he would have to stay on the job for a while, according to an aide who was present.

For months, Trump’s aides have told him he is unlikely to get $5 billion for the border wall in December, but he wants to show his supporters that he is fighting for the funding, according to two White House officials.

Pelosi tried to set the tone for Tuesday’s Oval Office confab. She told reporters later that she began by leading a prayer about King Solomon. She and Schumer sat on couches, with Trump and Vice President Pence seated in twin armchairs in front of a fireplace. Pence did not say a word, not even after Schumer mocked Trump for winning a Senate seat in the vice president’s home state of Indiana. Pence sat expressionless as he observed the fireworks.

The vice president was not the only observer, of course. The meeting was intended to be closed to the press, but White House staffers soon ushered in a pool of journalists to capture the exchanges. Although aides often urge him to keep such meetings closed to the media, Trump likes the visual of him at the center of a room leading a meeting with lawmakers because he looks like he is “in charge,” according to a former White House official.

On Tuesday, once the television cameras were rolling, Trump welcomed the Democratic leaders to the White House. He called it “a great honor.”

But the visit quickly devolved. Pelosi twice suggested they transition into a private discussion. “I don’t think we should have a debate in front of the press on this,” she said.

Critics accused her of trying to hide from the public, but Pelosi later told reporters that she did not want to embarrass the president by contradicting him “when he was putting forth figures that had no reality to them, no basis in fact.”

“I didn’t want to, in front of those people, say, ‘You don’t know what you’re talking about,’ ” Pelosi added.

During the meeting, as Trump insisted upon securing funding for his proposed wall — claiming a “national emergency” with drugs and disease pouring into the country — he suggested that Pelosi, too, might support the wall but was afraid to say so for fear of losing Democratic support for her bid to be speaker.

“I don’t think we really disagree so much,” Trump said. “I also know that, you know, Nancy’s in a situation where it’s not easy for her to talk right now.”

Pelosi’s rejoinder: “Mr. President, 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.”

Then Schumer entered with a zinger: “Elections have consequences, Mr. President.”

And so it went.

Pelosi and Schumer both took shots at Trump for misstating facts, such as his false claim that “tremendous amounts of wall have already been built.”

After Trump glanced from note cards to discuss border policy, Pelosi said, “His cards over there are not facts. We have to have an evidence-based conversation.”

And Schumer said, “We have a lot of disagreements here. The Washington Post today gave you a lot of Pinocchios, because they say you constantly misstate how much of the wall is built.”

Trump simply scoffed, as if to dismiss The Post’s Fact Checker, which this week debuted the “Bottomless Pinocchio” rating for false claims that a politician repeats at least 20 times.

Trump’s allies said his decision to argue with Pelosi and Schumer on camera was wise political strategy and argued that the Democratic leaders had to play to pressures from their liberal base.

“He knows they can’t be nice to him or their left wing will go crazy,” former House speaker Newt Gingrich (R) said. “If they had smiled, it would have caused a rebellion. He knew they’d do that and come across that way to the country.”

But Sen. Charles E. Grassley (R-Iowa) acknowledged that the televised clash “hasn’t solved one thing in terms of compromise.”

Back at the Capitol, reporters asked Pelosi whether the televised acrimony was indicative of the relationship she would have as speaker with the president.

“I don’t think so,” she said. “I think every day is a new day.”

In fact, every hour is a new hour. By late afternoon came word that Pelosi and Trump had spoken again by phone. The call was, Pelosi said, “constructive.”

Seung Min Kim and Sean Sullivan contributed to this report.