Cobb, 24, posted career highs with 91 catches, 1,287 yards and 12 touchdowns in 2014. He became just the fifth player in Packers history to record a 90-plus catch season.
Cobb and Jordy Nelson became the first receiving duo in NFL history to register 90-plus catches, 1,200-plus receiving yards and 12-plus touchdowns in the same season.
A year after missing 10 games because of a fractured leg, Cobb played in every game and was on the field for nearly 90 percent of the Packers' offensive snaps.
The 2011 second-round pick was in the final year of his rookie contract.
Although the exact structure of Cobb's contract was not immediately known, in terms of total money it is nearly identical to the contract extension Nelson signed last summer.
In that deal, Nelson got $39 million in new money over four years.
Cobb's deal means that he, Nelson and quarterback Aaron Rodgerswill be tied together through the 2018 season. Cobb and Nelson are signed for four more years, while Rodgers is under contract through 2019.
ESPN.com Packers reporter Rob Demovsky contributed to this report.
Cobb Agrees To 4-Year Deal With Packers
Dan Graziano discusses WR Randall Cobb's four-year, $40 million deal with the Green Bay Packers and how that will affect other free-agent receivers.