Financial terms were not disclosed.
Johnson, 45, trails only Roger Clemens (six) in career Cy Young Awards. He went 11-10 last season with a 3.91 earned run average in 30 starts for the Arizona Diamondbacks.
"We are extremely excited to bring Randy Johnson to the Giants organization," said Giants General Manager Brian Sabean. "Randy continues to be one of the most intimidating and competitive pitchers in baseball today. He commands respect and will have a dramatic influence on the way the 2009 team conducts business."
The San Francisco rotation for 2009 will include three Cy Young winners. Tim Lincecum won the award in the National League last year and Barry Zito was honored while with the Oakland Athletics.
No team has had three Cy Young winners in the same rotation since the 2002 Atlanta Braves, who had Tom Glavine, John Smoltz and Greg Maddux.
Johnson, who will be playing in his 22nd season, needs five wins to get to 300. He has struck out 4,789 batters, second all-time behind Nolan Ryan's 5,714.
Johnson pitched the most recent perfect game in the majors, a 2-0 Arizona victory over Atlanta in 2004.
Celebrity Families of 2014 [PHOTOS]