WASHINGTON — For 55 minutes, with cameras rolling, President Trump engaged in a vigorous discussion of immigration with congressional leaders of both parties in a setting usually reserved for bland talking points and meaningless photo opportunities.

In effect, the president and his visitors threw away the blah-blah scripts and negotiated possible legislation in front of the nation. “I hope we’ve given you enough material,” a pleased Mr. Trump joked with reporters as he finally ushered them out of the Cabinet Room in the White House.

That was the point. After days in which his very fitness for office was debated, Mr. Trump appeared intent on demonstrating that he could handle the presidency. He was in command of the meeting while inviting input. He did not berate anyone. He did not call anyone derogatory nicknames. He signaled that he was open to compromise.

The bar, of course, was historically low given that Democrats and even some Republicans have been describing him as so unstable that he should be removed from office. For his advisers, the meeting was a relief, a chance to reset the narrative and make Mr. Trump look more like a traditional president. And his critics, grading on a curve, called it a welcome change, a moment of constructive engagement that they hoped would lead to more.

Yet it was a measure of Mr. Trump’s political weakness that anyone seemed surprised.

He did not lapse into incoherence but neither did he demonstrate mastery of policy details after a year in office. At one point, Senator Dianne Feinstein of California seemed to lead him into agreeing to an immigration deal on terms that she and fellow Democrats have sought, only to have an alarmed Representative Kevin McCarthy of California, the House Republican leader, jump in to steer him back toward his own policy.

Indeed, Mr. Trump made clear once again that the details of governance do not really matter to him as much as success, telling congressional leaders that he would approve whatever they send him. “I will be signing it,” he said. “I’m not going to say, ‘Oh, gee, I want this or I want that.’ I’ll be signing it.”

The meeting was extraordinary in the sense that it played out in front of cameras and on the record. President Barack Obama on a few occasions participated in similarly extended conversations with congressional leaders in front of the news media, most notably a tense session with Republicans over health care.

But the news media more typically is invited into the room for only the first few minutes of such a meeting to record the traditional platitudes before being kicked out. After Tuesday’s meeting, lawmakers said that they were surprised Mr. Trump allowed cameras to stay and some noted wryly that they had become props in his latest reality television show.

Still, it was almost possible afterward to hear the collective exhale of Republicans who themselves nursed private doubts about the president’s capacity long before Michael Wolff’s new book, “Fire and Fury: Inside the Trump White House,” prompted the president to play up his “mental stability” and insist that he is a “very stable genius.”

Senator Lindsey Graham, Republican of South Carolina, who was a harsh critic when he faced Mr. Trump in the Republican primaries in 2016 but has lately become one of his chief allies, called Tuesday’s session “the most fascinating meeting I’ve been involved with in 20-plus years in politics.”

Democrats used other adjectives. “It’s fairly bizarre that the president has to show that he’s actually balanced and sane,” Senator Mazie K. Hirono, Democrat of Hawaii, said in an interview afterward.

Did he succeed in doing that? “More than some other kinds of other behaviors that he’s engaged in,” she said cautiously.

“It was more constructive than I believed it was going to be,” added Senator Michael Bennet, Democrat of Colorado. “I went into it thinking that it was just an opportunity to have a photo op and maybe allow him to demonstrate that he was not the person he was accused of being over the weekend. But I think it was more constructive than that.”

Mr. Trump used the occasion to suggest restoring the banned congressional practice of allowing members to designate money for projects in their districts, a process known as earmarks but conventionally called pork. For Mr. Trump, it was a nod to Washington institutionalists who say such spending makes it easier to forge legislative compromises, but it seemed to conflict with his promise to “drain the swamp.”

Mr. Trump’s outreach to Democrats came on the same day the “America First” president announced that he would travel this month to Davos, Switzerland, for the World Economic Forum, a gathering that is ground zero for the wealthy elite and globalist leaders that he has derided. By happenstance, it was the same day that Stephen K. Bannon, the architect of the president’s build-the-wall nationalist appeal and enemy of all things Davos, was pushed out of Breitbart News after his critical comments in Mr. Wolff’s book.

Added together, it gave the impression of a shift, but Mr. Trump has been down this road before. He broached the idea of comprehensive immigration legislation on the same day he addressed Congress for the first time nearly a year ago, then set about enacting some of the toughest anti-immigration policies in generations. He cut a short-term spending deal with Democrats in the fall, predicting a new bipartisan era, only to torpedo any follow-up with Twitter attacks and a move back to the right.

Recalling that, Democrats said they were curbing their expectations. But they held out hope that a coming spending deadline might force action. “I see all of the potential stars aligned,” said Senator Robert Menendez of New Jersey. “Doesn’t mean that it will happen. But I see the stars aligned for the possibility of something happening.”

He added that he could agree to concessions on bolstering border security and ending the diversity lottery visa program, two of Mr. Trump’s priorities, if the president likewise made compromises. “We’re willing to give,” Mr. Menendez said. “Some of these things for me are still hard, but I’m willing to do that if we achieve a real goal here and if Republicans are reasonable about what they’re seeking.”

As in the past, however, Mr. Trump got immediate pushback on Tuesday from conservative allies who quickly accused him of betraying the very promises he won the presidency on. In exchange for border security, he said he would sign legislation to replace the Deferred Action for Childhood Arrivals, an Obama-era program that protected younger immigrants who were brought into the country illegally as children but that Mr. Trump scrapped, citing legal grounds.

“This DACA lovefest confirms a main thesis of Michael Wolff’s book: When Bannon left. liberal Dems Jared, Ivanka, Cohn & Goldman Sachs took over,” Ann Coulter, the conservative commentator, wrote on Twitter, referring to Jared Kushner, Ivanka Trump and Gary D. Cohn, the president’s chief economic adviser. She added, “Nothing Michael Wolff could say about @realDonaldTrump has hurt him as much as the DACA lovefest right now.”

Mr. Trump said he was prepared for the pressure if the two sides moved beyond a quick initial deal and tackled a broader comprehensive immigration bill down the road.

“I’ll take the heat, I don’t care. I don’t care,” he told lawmakers. “I’ll take all the heat you want to give me, and I’ll take the heat off both the Democrats and the Republicans. My whole life has been heat. I like heat, in a certain way.”

The next weeks will test that because the temperature is sure to keep going up.

Correction:

An earlier version of this article misstated the room of the White House in which President Trump discussed immigration with congressional leaders. It was the Cabinet Room, not the Roosevelt Room.