Sen. Dianne Feinstein (D-Calif.) speaks during a hearing before the Senate Intelligence Committee on March 7 on Capitol Hill in Washington. (Alex Wong/Getty Images)

Former president Barack Obama endorsed Sen. Dianne Feinstein (D-Calif.) on Friday, as Feinstein seeks to fend off a liberal primary challenger, state Senate leader Kevin de León.

“I’m proud to give Dianne Feinstein my strong endorsement for her reelection to the United States Senate,” Obama said in a written statement. “She’s always been an indispensable leader for California, and we became dear friends and partners in the fight to guarantee affordable healthcare and economic opportunity for everybody.”

Feinstein and Obama served in the Senate together from 2005 until 2008. The California Democrat called Obama “a singular President with a remarkable legacy that will truly stand the test of time” in a statement. She said she was thankful for the support.

The endorsement comes as Feinstein has at times struggled to rally local Democrats behind her candidacy for a fifth full term. California Democrats denied Feinstein the party’s endorsement at a convention in February, giving a majority of votes to de León.

Under California’s nonpartisan primary system, all of the candidates will face off in a June 5 primary. The top two finishers will advance to the general election, regardless of party affiliation.