The Brewers also announced Thursday the signing of infielder Eric Sogard to a one-year contract.
Anderson's contract is guaranteed for $11.75 million for the two-year extension and could reach $31.35 million with incentives over the four years if the options are picked up, according to MLB.com.
Anderson, 29, who was arbitration-eligible, was 12-4 with a 2.74 ERA in 25 starts this season.
"Signing Chase to a multiyear contract furthers our strategy to acquire, develop and retain talent throughout our organization," general manager David Stearns said in a statement. "Chase's 2017 performance elevated his stature in the game and demonstrated that he has the capability to lead a rotation. Since he arrived in Milwaukee, Chase has been a model contributor to our community both on and off the field. We are happy for him and his family and look forward to Chase's contributions for years to come."
The Brewers acquired Anderson from the Arizona Diamondbacks in a multiplayer trade last year.
He is 36-28 with a 3.87 ERA in 560 innings pitched over 104 career games (103 starts).
Sogard, 31, batted .273 with three home runs and 18 RBIs in 94 games this season with Milwaukee after missing all of 2016 with a left knee injury.
"Eric brings to the team a veteran presence who possesses the ability to play multiple positions and reach base at a high rate," Stearns said. "We are pleased to welcome Eric and his family back to Milwaukee for the 2018 season."