California Democrats may have spurned Sen. Dianne Feinstein at their party convention, but Republicans are willing to listen to her. Count President Trump among them.

At a White House summit on gun violence this past week, Trump urged Republicans and Democrats to include Feinstein’s priorities in any legislation, even suggesting including her long-sought bid to restore a ban on assault weapons. Sitting at his side, she gleefully clasped her hands.

Any cooperation with Trump, even a good-faith effort on immigration or gun control, is anathema to California Democrats, who see themselves as the vanguard of the resistance movement. Last weekend, the California Democratic Party declined to endorse Feinstein’s reelection bid and cast more ballots for state Sen. Kevin de León, who has launched the best-organized primary challenge to her since she won her seat in 1992.

The rebuke was a political blow to Feinstein, with Democrats clamoring for a next-generation senator with a more liberal record. At 84, Feinstein is the oldest U.S. senator, the first time a woman has reached that status, and at times on Capitol Hill she has struggled in fast-paced interactions with reporters, misspeaking or forcing staff to explain what she meant.

Feinstein’s experience, however, and California’s open primary system may work to her advantage. In June voting, she could attract support from GOP and independent voters looking for a pragmatic lawmaker with a track record of working with Republicans as California’s debilitated GOP struggles to field a viable candidate.

“Will I vote for her? Compared to some progressive crazies like Kamala Harris? Yeah,” said Rep. Darrell Issa (R-Calif.), referring to the state’s other Democratic senator. “Our senior senator has been liberal. She just isn’t liberal enough for the Democratic Party anymore, apparently.”

Rep. Doug LaMalfa (R-Calif.), who has worked with Feinstein on water issues, said he always has “to play my Republican card first” but that “given the choice between she and any other Democrats I see out there, she’s the one I’d see as much more workable given that’s she’s already in the stream on these issues.”

Feinstein remains confident of her chances, dismissing the party convention snub and describing herself as a “lifelong Democrat.” She holds a comfortable lead in the polls and a daunting edge in fundraising — she’s raised more than $9.8 million, including a $5 million personal loan, compared with de León’s $359,261 in the bank at the end of the last quarter, according to the Federal Election Commission.

Asked about targeting independent and Republican voters, she said, “We’ve always made the broadest reach possible . . . I would assume I’m going to run a statewide campaign for everybody.”

The election-year question is whether Feinstein’s pragmatism is acceptable in an increasingly liberal state clamoring for defiance.

“People don’t want complacency or patience. I believe that California’s leaders should be fighting for California’s values at a time when we’re in the fight for the soul of our nation against a president without one,” said de León.

Asked how he will try to contrast himself with Feinstein, de León, 51, pointed to his record on environmental policy, his push for a $15 federal minimum wage and his support for “Medicare for All.” He criticized Feinstein’s previous support for a bill that would punish cities and states that refuse to help enforce federal immigration laws — a stance she later dropped — and her original support for wars in Iraq and Afghanistan that have cost trillions of dollars.

Rep. Ro Khanna (D-Calif.), who is backing de León, agreed, calling Feinstein “out of touch” with California’s values on economic policy and foreign policy. He called the Iraq War “the largest blunder in 21st-century foreign policy” and criticized her support for the Patriot Act, Bush-era tax cuts and for not supporting “a populist economic platform.”

De León’s interest in running was sparked in part by comments Feinstein made in August about Trump in San Francisco.

“Look, this man is going to be president, most likely for the rest of this term,” she said at an event hosted by the Commonwealth Club. “I just hope he has the ability to learn, and to change. And if he does, he can be a good president. And that’s my hope.”

Last month, Trump came close to endorsing Feinstein’s Democratic-backed plan to legalize young immigrants before Republicans at a White House meeting stopped him. And last year, Trump even consulted with Feinstein before nominating Neil M. Gorsuch to the U.S. Supreme Court.

In the gun summit moment with Trump at the White House, Feinstein recounted how she was thrust to the top of San Francisco politics after the assassination of two colleagues in 1978. San Francisco Mayor George Moscone and San Francisco Supervisor Harvey Milk were killed by Dan White.

Feinstein said local police “gave me a weapon. They taught me how to shoot it, and we proceeded through the 1970s that way.”

Asked on Friday about the meeting and her ability to persuade Trump, she said, “I wish I had some charm to pull out and say, abracadabra,” and make Trump change his mind.

Watching from California, de León said he respected Feinstein for what she was trying to accomplish.

“However, I am wary of trusting a president who has betrayed both Democrats and Republicans on deals like this before. I’ve seen this movie before, and it has a bad ending,” he said.

When it comes to de León, Feinstein clearly considers him a non-factor.

“I’ve not met him,” she said.

But that’s not true.

The two met in mid-January in Feinstein’s Washington office when he visited Capitol Hill to lobby for legislation supporting young immigrants. De León later tweeted about the 40-minute meeting.

When a staffer interjected on a phone call to remind her of the meeting, Feinstein said, “Oh, that’s right; I did. Yes, he was quite pleasant.”

Feinstein is one of eight octogenarians in the Senate — some who are often shielded from reporters for fear of misstatements. But Feinstein still engages reporters eager to question the top Democrat on the Judiciary Committee and a senior member of the Intelligence panel.

Sometimes the rapid questioning in the Senate hallways can catch her off guard.

In one recent encounter, Feinstein told a Washington Post reporter that she supported efforts by Judiciary Committee Chairman Charles E. Grassley (R-Iowa) to publicize classified information behind a Republican-drafted memo and criminal referral blasting the authors of a now-famous dossier alleging Trump has Kremlin ties — a major break from other Democratic leaders, who had accused Republicans of trying to undercut federal law enforcement agencies.

When the reporter tweeted out the news, her spokesman rushed to undo Feinstein’s statement, saying that the senator had been asked “so many questions today about a whole range of documents” that she had accidentally “conflated” matters.

On a day in January during the contentious debate over immigration, she told a reporter that she would be voting for a proposed short-term spending plan — putting her at odds with most of her caucus. She reversed course later in the day with a written statement, clarifying that she was opposed to the bill because it didn’t sufficiently protect young undocumented immigrants.

But age doesn’t seem to be a factor for Californians, who appear to favor older political leaders. The state is run by 79-year-old Gov. Jerry Brown, and its best-known Democrat, House Minority Leader Nancy Pelosi, is 77.

Rep. Lucille Roybal-Allard (D-Calif.), 76, who was elected to Congress in 1992 — the same year as Feinstein — said she supports the senator and considers her age an advantage.

“We are becoming an older country, so the issues of senior citizens and what their concerns are, health-wise, in particular — she would be more in tune with the issues that seniors are facing than somebody else,” she said.

Rep. Anna G. Eshoo (D-Calif.), 75, who also supports Feinstein, said age is a fair question, but it’s “answered when you see what somebody’s work product is. This is not a confused work product; this is a serious work product that she refines, she brings all of herself to it, and she’s got guts and determination.”

Karoun Demirjian and Erica Werner contributed to this report.

Correction: An earlier version of this report incorrectly stated that Sen. Dianne Feinstein tweeted about her January meeting with California state Sen. Kevin de León. Only he did.