The 38-year-old Kratz hit .125 (4-for-32) in 15 games for San Francisco. He was designated for assignment on Tuesday.
As part of the trade announced Thursday, the Giants agreed to send the Rays $471,613 to cover a majority of the $877,419 remaining in Kratz's $1.2 million, one-year contract. San Francisco will receive a player to be named or cash.
The Giants acquired Kratz in a March 24 trade with Milwaukee for minor league infielder C.J. Hinojosa. Kratz helped the Brewers make it to the NL Championship Series last year, batting .292 with three RBIs in nine playoff games.
Kratz broke into the majors with Pittsburgh in 2010. He is a .208 hitter with 31 homers and 101 RBIs in 310 career games.