Jake Peavy has reached an agreement on a two-year, $24 million contract with the San Francisco Giants.

The deal will pay Peavy base salaries of $7 million in 2015 and $13 million in 2016, the source said. It includes a $4 million signing bonus, a full no-trade clause and an awards package.

Jake Peavy went 6-4 for the Giants in 2014 after a midseason trade brought him to San Francisco. Denny Medley/USA TODAY Sports

Peavy, 33, is 139-111 with a 3.53 ERA in parts of 13 seasons with San Diego, the Chicago White Sox, Boston and San Francisco. He is a three-time All-Star who won the National League Cy Young Award with the Padres in 2007.

After struggling in Boston last season with a 1-9 record and a 4.72 ERA in 20 starts, he put in a strong performance in August and September with the Giants after they acquired him from the Red Sox on July 26 in a trade for minor league pitchers Edwin Escobar and Heath Hembree.

Peavy went 6-4 with a 2.17 ERA and 2.1 wins above replacement with San Francisco to help the Giants make the playoffs as a wild-card entry. He threw 5⅔ shutout innings against Washington in the opener of the National League Division Series but finished the season on a down note, lasting only 1⅓ innings in a 10-0 loss to Kansas City in Game 6 of the World Series.

The Atlanta Braves and Miami Marlins were among the teams that expressed interest in Peavy before he elected to return to San Francisco.

The Giants will slot Peavy into a rotation that currently includes Madison Bumgarner, Matt Cain, Tim Hudson and Tim Lincecum. San Francisco made a strong pursuit of free agent Jon Lester before he signed with the Chicago Cubs last week.

A baseball source said the Giants also are "in the mix" for James Shields, the third-most prominent starter behind Max Scherzer and Lester on the market this winter.

Foxsports.com earlier reported news of Peavy's agreement with the Giants.