President Donald Trump took command of a high-profile White House meeting on immigration Tuesday, coaxing Republican and Democratic lawmakers toward a compromise on the fate of undocumented migrants who came to the United States as children.

Trump also signalled he was open to more comprehensive immigration reform to address millions of other undocumented people living in the shadows but did not give ground to Democrats over his plans for a border wall.

"It should be a bill of love," Trump said of a measure under negotiation that would protect hundreds of thousands of so-called "Dreamers" from deportation.

"But it also has to be a bill where we're able to secure our border. Drugs are pouring into our country at a record pace. A lot of people are coming in that we can't have," Trump added, urging lawmakers to "put country before party" and strike a quick solution.

Trump, seated at a long table with some two dozen lawmakers from the House and Senate, presided over the bipartisan talks, allowing journalists rare access to nearly an hour of the meeting.

The president said he would "take the heat" politically if lawmakers were to move toward broader action that would provide a pathway to citizenship for about 11 million undocumented immigrants living in the United States.

"You are not that far away from comprehensive immigration reform," he told Senator Lindsey Graham, after the Republican lawmaker floated the idea of more sweeping legislation.

"You created an opportunity here, Mr President, and you need to close the deal," Graham told him as TV cameras rolled.

Trump's position appeared at odds with his 2016 campaign when his platform focused largely on border security and immigration curtailment, and many of his core supporters raged at the prospect of legalizing millions of undocumented immigrants.

The image of Trump presiding over such sensitive negotiations appeared tailor-made for the White House to push back against a narrative -- fueled by a recent explosive West Wing expose -- questioning Trump's mental fitness, with aides were doubting his ability to govern.

Lives 'in the balance'

In September, Trump said he was scrapping the Deferred Action for Childhood Arrivals (DACA) program, but then delayed enforcement to give Congress six months -- until March -- to craft a lasting solution.

So-called "Dreamers" were protected from deportation under the policy enacted during Barack Obama's presidency.

On Tuesday, Trump said a "permanent" solution was needed for Dreamers, but also insisted on the importance of border security, especially with Mexico.

"We need a wall," Trump said.

Any deal, he added, would need to be accompanied by money for a border wall, measures that limit immigrants from bringing family members into the country in the future -- a policy known as "chain migration" -- and an end to the green card lottery system.

White House spokeswoman Sarah Sanders said the group had agreed to negotiate legislation that accomplishes "critically needed reforms" in the above areas, as well as DACA.

But a path through Congress remained unclear. The two parties were at odds over whether to pass the measure as a stand-alone bill, as Senate Republican leadership wants, or attach it to a federal spending package that must pass by January 19 in order to avert a government shutdown.

Senate Majority Leader Mitch McConnell said he will bring up a narrow, DACA-related measure unattached to budget issues or broader immigration reforms.

"There are a number of moving parts here that need to be dealt with," McConnell told reporters after the meeting, but DACA "will not be a part of any overall spending agreement."

McConnell nonetheless expressed optimism that a DACA fix could be complete before the March deadline when the grants of legal status begin expiring.

Senate Democrat Dick Durbin, a leading proponent of codifying immigration protections, noted that about 1,000 people per day will lose their DACA status beginning March 5.

"Lives are hanging in the balance," said Durbin, who was seated next to Trump. "We've got the time to do it."

Not all lawmakers were optimistic about a solution.

"I don't think they're closer," said Republican Senator John Kennedy, who was not at the talks.

"The problem is that the Democrats, they want all the dessert and they don't want to eat any spinach," he added. "They're just dying to give amnesty to somebody."