SAN FRANCISCO — House Minority Leader Nancy Pelosi’s recent closed-door talks with President Donald Trump have shaken up Washington, D.C., and led to a possible breakthrough on protecting young undocumented immigrants.

But Pelosi got a taste of the danger any California Democrat faces in getting too close to Trump when a group of angry young protesters hijacked her San Francisco news conference on Monday morning to denounce her negotiations with the president.

About 40 young protesters, including undocumented immigrants, surrounded her and unveiled protest banners as she prepared to discuss her work to pass the Dream Act in an event at College Track, an education nonprofit in San Francisco’s Bayview neighborhood.

Shouting at the top of their lungs, the protesters harangued Pelosi for using recipients of the Deferred Action for Childhood Arrivals (DACA) program, known as Dreamers, as “bargaining chips” in negotiations with Trump, and for being “complicit” with stepped-up deportations under the eight years of the Obama administration.

“You met with Trump and you call that resistance?” they chanted. “This is what resistance looks like!”

Pelosi, who looked on uncomfortably from the middle of the protest, tried several times to talk with the demonstrators, telling them, “I totally agree with you.” But she barely got a few words in edgewise as they continued their call-and-response chants.

After about 30 minutes of ceaseless protest, Pelosi walked out the back door of the building, followed by Reps. Barbara Lee, D-Oakland, and Jared Huffman, D-San Rafael, who were also at the event.

The reception Pelosi received shows the difficult tightrope she’s walking when it comes to Trump, said Bruce Cain, a Stanford political science professor: If she refuses to work with the president, she might not pass the Dream Act, which would protect young undocumented people brought to the U.S. illegally as children. But if she gets too close to Trump, she’ll face the wrath of liberal activists.

In recent weeks, Pelosi and Senate Minority Leader Chuck Schumer, D-N.Y., have held several meetings with Trump, and last week announced that they were making progress toward a deal that would involve passing the Dream Act in exchange for some border security measures. Any agreement would not include funding to build Trump’s signature policy goal, a wall on the U.S.-Mexico border, the Democratic leaders stressed.

Many of the protesters said they opposed that deal, and others said that they opposed the Dream Act because it only covers some of the roughly 11 million undocumented immigrants in the United States. The bill would essentially replace provisions of the DACA program put in place by Obama, which Trump has said he will rescind within six months.

Undocumented protesters again shout down Pelosi as she tries to tell them "I totally agree with you" pic.twitter.com/thITAnBX4I — Casey Tolan (@caseytolan) September 18, 2017

The original schedule for Pelosi’s event had included speeches by four Dreamers about their experiences, but none of them were able to speak amid the uproar.

“I understand their frustration — I’m excited by it, as a matter of fact — but the fact is they’re completely wrong,” Pelosi told reporters on the sidewalk outside the building, as protesters continued chanting inside. Democrats are fighting deportations, she said, and “we are determined to get Republican votes to pass the clean Dream Act.”

Pelosi said she has to negotiate with the president because “Trump has the signature. Basically our conversation with Trump is, ‘We don’t want to hear about anything that you may want to do unless we have shared values around the Dreamers.’ That’s our threshold.”

“I wish (the protesters) would channel some of that energy into the Republican districts so we can pass the Dream Act,” she added.

Pelosi walks out of her own press conference, shouted down by undocumented protesters pic.twitter.com/xM9zwByvNu — Casey Tolan (@caseytolan) September 18, 2017

Protesters said in interviews after the event that they were worried Pelosi’s negotiations with Trump would lead to increasing militarization of the border, or stricter enforcement of immigration laws against undocumented people who weren’t protected by DACA.

“It should be the cleanest bill possible,” said David Buenrostro, 26, a DACA recipient from Oakland. He said the Dream Act shouldn’t be passed “at the expense of our parents or other community members who aren’t necessarily DACA recipients or shielded from deportation.”

“We took over the press conference because it has been so long that we haven’t been at the table,” Buenrostro said. “They should have input from our community.”

Other immigrant rights leaders were frustrated with the young protesters’ tactics, especially at a critical time for Congressional action. “I don’t think it’s productive to be attacking people who have supported Dreamers and immigration justice for years,” said Mark Silverman, an attorney with the Immigrant Legal Resource Center in San Francisco.

A poll by the Berkeley Institute of Governmental Studies released last week found that a plurality of California Democrats think someone else should lead House Democrats after the 2018 election — 44 percent said Pelosi should go if Democrats retake the House, while 50 percent said she should go if Democrats don’t retake it.

A Berkeley poll in March found that a bipartisan majority of Californians support immigration reform that gives undocumented immigrants a pathway to citizenship.

Pelosi isn’t the only longtime California Democratic leader facing anger from the party base: Sen. Dianne Feinstein has also been heckled at recent Bay Area appearances for her refusal to resist Trump’s administration at every turn.

“Nancy’s just not going to go that direction of ideological purity over winning, because she has an obligation as leader to try to look out for the party as a whole,” Cain, the Stanford professor, said. “It’s another of many signs that the Democratic Party really has a challenge to hold its ranks together.”