SAN DIEGO — Didi Gregorius will hold a distinct place with the Yankees for the way he handled a difficult job, succeeding Derek Jeter at shortstop with production and leadership.

But now the Yankees will have to find his successor.

Gregorius agreed Tuesday to a one-year, $14 million contract to reunite with new Phillies manager Joe Girardi. Gregorius will try to reestablish value in 2020 and head back into free agency for a bigger (longer) payday next offseason.

Gregorius had his best season in 2018 with 27 homers and an .829 OPS, but he finished the year needing Tommy John surgery. He did not return in 2019 until early June and never seemed fully comfortable or confident on defense or able to consistently turn on inside fastballs at the plate like he had in his past. He finished with just a .718 OPS.

Gregorius does not turn 30 until February, so if he is back in full, the lefty swinger is an excellent bounce-back candidate, hitting at another favorable home stadium, Citizens Bank Park.

The Yankees had rejected the chance to give Gregorius the $17.8 million qualifying offer. They seemed concerned his defense would not fully return to form. Plus, they were looking to save money where possible, with a particular eye on pursuing Gerrit Cole.

Gleyber Torres played competently at short first in place of Gregorius and then in tandem. The Yanks could begin next season with Torres at short, DJ LeMahieu at second, Luke Voit at first, Gio Urshela at third and Miguel Andujar bouncing between first and third. They would hope Thairo Estrada or Tyler Wade could handle the backup shortstop role.

But once they know if Cole is coming or not, the Yanks should have a clearer view of how much they can budget for a shortstop, with the preference being defensive acumen and — if possible — a lefty bat. The Yanks have always liked Cincinnati’s Freddy Galvis, due $5.5 million in 2020. The possibility of landing him would have been far greater if Gregorius had gone to the Reds, who originally signed him in 2007 and were interested in a reunion.

The Angels were willing to give up their first-round pick from last June’s draft, shortstop Will Wilson, to the Giants to rid themselves of the $12.67 million owed Zack Cozart in 2020. That allowed them to free up more money to pursue Gerrit Cole — or other starters if Cole signs elsewhere — and also look into third basemen Anthony Rendon or Josh Donaldson.

Cozart signed a three-year, $38 million pact, and in two poor, injury-filled seasons managed to hit .190 in 96 games.

The Giants also signed free-agent righty Kevin Gausman to a one-year, $9 million pact.