Democratic lawmakers shut out of governance for much of this year now find themselves at the center of high-stakes negotiations with President Trump that could achieve a prize they have sought for nearly a decade: permanent legal status for hundreds of thousands of undocumented immigrants.

For a small but vocal contingent of Democrats, these talks are fraught with peril, largely because of their total distrust of a man who began his presidential campaign two years ago describing illegal immigrants from Mexico as rapists.

But for Senate Minority Leader Charles E. Schumer (D-N.Y.) and House Minority Leader Nancy Pelosi (D-Calif.), there is little to lose. If the deal falls apart and Trump returns to his pattern of insult-hurling and name-calling, the Democratic leaders will be right where they began — no better and no worse. And a successful negotiation would achieve something they failed to pull off when their party controlled both Congress and the White House. It could also serve as a road map for more achievements to come.

“Nothing ventured, nothing gained,” Schumer said in an interview. “We thought we had an opportunity to get something good done, and let’s see what happens. We’re very hopeful that they will keep their word.”

Schumer and Pelosi are pressing ahead with the president’s top advisers, hoping to reach a deal in a matter of weeks to enshrine in law an Obama-era executive order called Deferred Action for Childhood Arrivals. It protects from deportation undocumented immigrants brought to the United States as children. Trump has criticized DACA as executive overreach, but he has also expressed empathy for the young immigrants it protects.

President Trump meets with congressional leaders in the Oval Office on Sept. 6, 2017. From left are Vice President Pence, Trump, Senate Majority Leader Mitch McConnell R-Ky.), Senate Minority Leader Charles E.Schumer D-N.Y.) and House Minority Leader Nancy Pelosi D-Calif.). (Bill O'Leary/The Washington Post)

There is one critical stumbling block to the whole effort to pass a Dream Act to replace DACA: how much additional border security and enforcement Trump will demand.

The deep fear among Democrats skeptical of the negotiations is that, in exchange for permanent protections for “dreamers,” Trump will win broad new powers and resources to enforce immigration laws that go beyond adding more agents or technology along the border. The cost of a permanent Dream Act, they say, could be a new and emboldened deportation force across the nation that undermines civil liberties and terrorizes law-abiding immigrants.

“We’re going to have to be very leery and very careful of the slippery slope,” said Rep. Luis V. Gutiérrez (D-Ill.).

“There is no fresh start with Trump, and I don’t trust him,” said Rep. Raúl M. Grijalva (D-Ariz.).

Washington heads are still spinning from a negotiating dynamic that no one expected — not Schumer and Pelosi, and not their Republican counterparts, House Speaker Paul D. Ryan (R-Wis.) and Senate Majority Leader Mitch McConnell (R-Ky.).

Trump spent his first seven months in an entirely partisan bubble, working only with Republicans trying, and failing, to pass conservative legislation — notably a replacement to the Affordable Care Act. And it was less than a month ago when Pelosi said Trump should be formally censured by Congress for how he responded to the violence surrounding the white supremacist gathering in Charlottesville.

But Trump’s frustration with GOP leaders reached a boiling point during the failed effort to repeal President Barack Obama’s signature health-care law, losing in the Senate by one vote when three Republicans opposed Trump. From the White House’s perspective, that frustration — and Trump’s pivot to working with Democrats — is justified.

“Republicans have shown they can’t keep 50 out of 52 members in line, even after six years of promise to repeal and replace Obamacare when given the opportunity,” said Marc Short, Trump’s director of legislative affairs.

Congressional Republicans, for their part, worry that Pelosi and Schumer could outsmart Trump. The two are seasoned dealmakers with combined service of more than 65 years on Capitol Hill, while Trump is a newcomer who honed his negotiating skills in real estate. Republicans have noted in particular how Trump and Schumer — one raised in Queens, the other in Brooklyn — are bonding over their outer-borough roots, leaving the president, they fear, vulnerable to getting the short end of the deal.

Trump’s closest advisers are enjoying the theater of how quickly allegiances are ebbing and flowing from week to week. “Washington will never keep pace with Trump speed,” Kellyanne Conway, counselor to the president, said in an interview. “A non-politician’s measure of progress is fundamentally different than that of Washington. It’s grounded in business, it’s grounded in results, it’s grounded in performance.”

One senior White House official, speaking on the condition of anonymity to comment on internal discussions, said Trump sees Schumer as an exciting and energetic contrast to McConnell, whose default posture is intense silence. Trump sees McConnell’s deep knowledge of pulling levers of powers as a perfectly fine skill but one that is at odds with Trump’s stated goal of disrupting the traditional, establishment-driven ways of Washington.

The majority of rank-and-file Democrats, as well as liberal activists around the nation, are willing to give Schumer and Pelosi room to maneuver. Progressive organizers, who had scorched Democrats for voting to confirm Trump’s Cabinet nominees, have generally held their fire so far on the bipartisan DACA talks eight months after some of them had surrounded Schumer’s Brooklyn home chanting, “Chuck’s a chicken.”

“They’re in this position because there’s been a whole national movement, years in the making, on behalf of the dreamers,” said Héctor Figueroa, a New York labor organizer who is co-chairman of the progressive Working Families Party.

For now, Schumer and Pelosi have taken a page from President Ronald Reagan’s old “trust but verify” adage toward the Soviets. They say that they have convinced Trump that protecting immigrants currently covered by DACA is the right policy and the right political move for a president with poor approval ratings.

“Look, he said he would do this,” Schumer said. “I take him at his word that he will.”

Pelosi at first deflected a question about whether she trusts Trump.

“Is that a fair question?” she asked reporters last week, before finally saying that, on this issue, she does, indeed, trust him. “I believe that the president, [not only] because of conviction, but because of reality, is there for the dreamers.”

Critical challenges ahead could hobble the emerging deal. One is the uncertainty surrounding an erratic president, whose engagement with Democrats — on immigration, and a week earlier on short-term fiscal policy and hurricane relief — was not expected and not part of a grand plan.

“I’m not sure there is a broader strategy,” said Rep. Joseph Crowley (D-N.Y.), a lieutenant in Pelosi’s leadership team. “I don’t think we should be surprised if he comes back next week, and he’s working with Republicans only. It’s a case-by-case basis.”

Regarding the scope of border-security measures, Schumer said he signaled support for four points of toughened security: electronic surveillance at the Mexican border, detection devices focused on drug smugglers, improved infrastructure along the border and more search helicopters.

But Ryan, trying to reassert the power of congressional Republicans, added something to the talks. “We need border security and enforcement as part of any agreement,” he said Thursday, the morning after Trump’s White House huddle with the two Democrats.

The “enforcement” portion of his remarks set off alarm bells in the Hispanic caucus. “Where is it going to lead, once the alt-right starts raising their voices, which they’ve already begun and will only become louder?” asked Gutiérrez, referring to the white nationalist movement that has supported Trump and loudly advocated for tougher immigration enforcement.

These Democrats, for instance, will not support a deal to add thousands of agents nationwide to the Immigration and Customs Enforcement agency, a step they forecast would lead in turn to a surge in deportations.

Another potential dealbreaker is the question of whether dreamers would be given a path to citizenship or merely permanent legal status. Pelosi and Schumer said they were specific with Trump in explaining that he would support the Dream Act introduced by Sens. Lindsey O. Graham (R-S.C.) and Richard J. Durbin (D-Ill.), which includes opportunities for full citizenship.

On Thursday, Trump went back and forth on this issue, at times seeming to endorse the Democratic version of events but then backing away from citizenship, which staunch conservatives vehemently oppose.

Ultimately, if the deal comes together, it is most likely to happen fast — in weeks and not months, Schumer said. “I’d like to see it within the next little while. Look, I don’t want to set a date. Soon. Soon is the right word.”

Kelsey Snell and David Weigel contributed to this report.