The teams have not confirmed the deal for Longoria, who has five seasons remaining on a six-year, $100 million contract that also includes a seventh-year club option.
Per Yahoo Sports, the Rays will receive infielder Christian Arroyo, minor league pitchers Matt Krook and Stephen Woods and must take on the last year of outfielder Denard Span's contract, which is for $9 million.
Longoria has spent his entire 10-year career with Tampa Bay, winning Rookie of the Year honors in 2008 and claiming his third Gold Glove Award in 2017.
The 32-year-old batted .261 with 20 homers and 86 RBIs last season and is hitting .270 with 261 homers and 892 RBIs in his career.
Arroyo, who is the Giants' first-round pick in 2013, played in 34 games after making his major league debut in 2017.
Span, who will turn 34 in spring training, batted .272 with 12 homers and 43 RBIs last season.
Krook, a left-hander, and the right-handed Woods played in High-A baseball last year.