The deal is for $14 million, NBC Sports Philadelphia reported.
Gregorius, who turns 30 in February, came back from Tommy John surgery in early June and hit .238 with 16 homers and 61 RBIs in 82 games. He was arguably one of the Yankees' best players before he needed ligament reconstruction in his right elbow after injuring himself while making a throw during the 2018 AL Division Series against the Boston Red Sox.
From 2016 to '18, Gregorius averaged more than 20 home runs per season, and he broke the club record for home runs by a shortstop with 27 in 2018. He drove in a career-high 87 runs in 2017 and 86 the next year.
The move, which reunites Gregorius with his former manager in New York, first-year Phillies skipper Joe Girardi, comes on the heels of Philadelphia signing free-agent pitcher Zack Wheeler.
Beyond his offensive stats, Gregorius -- popular with his teammates and a fan favorite -- was the anchor of the Yankees' infield and provided Gold Glove-caliber defense at shortstop. He will take over for Jean Segura, who could move to second or third base with Scott Kingery likely manning the position Segura doesn't fill.
The Yankees acquired Gregorius in the 2014 three-way trade that saw Robbie Ray end up in Arizona and Shane Greene in Detroit.
"Didi has been a great player for us," Yankees manager Aaron Boone said Tuesday. "He's a great person. Somebody that's obviously been there before I got there and just kind of -- I followed his career because he came up with Cincinnati and then was out in Arizona, so I was familiar with him. To come in and replace Derek [Jeter] the way he did, he's had a great career to this point.
"And I think, obviously, going into winter where he's healthy, [I] would expect a really full, productive season seen from him."
Named Mariekson Julius Gregorius, he was born in the Netherlands and grew up in Curacao, a Dutch territory until 2010 that is now a constituent country of the Kingdom of the Netherlands. Among the other active major leaguers from Curacao are Kenley Jansen, Ozzie Albies, Jurickson Profar, Jonathan Schoop and Andrelton Simmons.
The New York Post was first to report the Phillies' agreement with Gregorius.
ESPN's Marly Rivera contributed to this report.
Will the Phillies get Bryant after signing Didi?
With the Phillies signing Didi Gregorius, Buster Olney says the team is also interested in acquiring Kris Bryant.