The Royals will receive a player to be named later and will pay part of Guillen's remaining contract, the Giants said on their website (http://sanfrancisco.giants.mlb.com).
The 34-year-old native of the Dominican Republic is making $12 million this season, the final year of a three-year contract.
Guillen, who has played in the majors for 14 years, hit .255 with 16 home runs and 62 RBIs with Kansas City. He was designated for assignment on August 5.
The Giants trail the front-running San Diego Padres by 2.5 games in the National League West.
(Reporting by Gene Cherry in Raleigh, North Carolina. Editing by Steve Ginsburg))