Sen. Dianne Feinstein, D-Calif., said Wednesday that she no longer supports the death penalty, a reversal of nearly three decades of public statements that comes amid a primary challenge from the left wing of the Democratic party.

"It became crystal clear to me that the risk of unequal application is high and its effect on deterrence is low," Feinstein said Wednesday, adding that her change of heart came "several years ago."

But she hasn't discussed it publicly until now, just weeks before the June 5 primary in her bid for a fifth full term in Washington. Feinstein's toughest challenger appears to be Democratic state Sen. Kevin de Leon, who has argued she's out of touch with California values.

The two candidates with the highest number of votes in the primary advance to November regardless of party, and there are no prominent Republicans in the contest.

De Leon blocked Feinstein from receiving the California Democratic Party's endorsement at its annual convention in February, a window into her troubles with some of the activist base. De Leon seized on her death penalty shift as further evidence that Feinstein is worried about her base of support.

"This latest flip on the death penalty is yet another appeal to California voters who have outgrown her centrist bent," de Leon spokesman Jonathan Underland said.

Still, Feinstein remains popular and has a significant edge on de Leon in name recognition and money, two critical elements for a successful statewide campaign. She's run successful campaigns in the past by picking up Democrats as well as California's independent voters, who now make up almost as large a share of the electorate as Republicans.

During Feinstein's unsuccessful run for California governor in 1990, she aggressively touted her support for capital punishment at the ire of Democratic activists, who booed her at the party's annual convention.

She ran a television ad declaring that she was "the only Democrat for governor for the death penalty."

She won the party's nomination but lost the general election to Republican U.S. Sen. Pete Wilson. She maintained the position in her successful 1992 campaign for U.S. Senate and in subsequent campaigns.

California has since become a more heavily Democratic state and has not elected a Republican to the U.S. Senate since Wilson won a second six-year term in 1988. Wilson later resigned to run for governor and Feinstein was elected to his old seat in 1992.

Feinstein gave a nod to the state's changes earlier this year when appearing to shift her stance slightly on marijuana. She vehemently opposed a state proposition to legalize recreational marijuana in 2016, but said in early May that she would consider legislation granting protection to states that have legalized the drug.

Her office did not offer a clear answer on whether she broadly supported legalized recreational marijuana.

De Leon similarly claimed that change was evidence that Feinstein was out of touch with current voters.

The Associated Press contributed to this report.