With the extension, his salary will be $20 million in 2016-17, and $21 million in '17-18.
Porcello, who was acquired during the offseason in a trade with the Tigers for Yoenis Cespedes, would have been eligible for free agency after the season.
"Obviously I knew the opportunity in entering free agency," said Porcello, "but when I had first got to camp and saw the way from ownership to [general manager] Ben [Cherington] to the coaching staff and the players that were there, and how everything was run from top to bottom, and the devotion to win a World Series here, I knew that as something I wanted particularly to be a part of it. It wasn't a very difficult decision for me at that point to stay here."
Now, the Red Sox have locked up an emerging starting pitcher through the 2019 season.
The Red Sox negotiated with lefty Jon Lester while he was still under their employ last spring, and even into the early portion of the season, but to no avail. They lost out on Lester to the Cubs in free agency this winter.
The 26-year-old Porcello is five years younger than Lester.
"We think Rick's a really good pitcher and we think he's a very talented pitcher who's driven to succeed and driven to be as good as he can possibly be," said Cherington. "As I said before, in any negotiation, there's all sorts of variables. Performance is one of them, talent is one of them, age is one of them, team need is one.
"There's all sorts of variables you have to consider, and that was no different in this case. We're extremely happy that he's going to be a Red Sox for a long time."
Porcello will make his debut for his new team on Wednesday night against the Phillies.
The deal was announced less than two hours after the Red Sox opened the 2015 season with an 8-0 rout of the Phillies.
"Honestly, the negotiations were kept between Ben and my agent," said Porcello. "I wanted to focus on Spring Training and getting ready for the season. That was first and foremost in my mind. Over the past couple of days is when things started to get to that realm and that was when I felt like I had a decision to make.
"Over the course of Spring Training and getting to know everybody within the organization, it was a pretty easy decision for me. It's something I want to be a part of. I'm very grateful and fortunate for the opportunity."
Porcello has a career record of 76-63 with a 3.43 ERA, spending his first six seasons with the Tigers. Last year was the best of Porcello's career, as he went 15-13 with a 3.43 ERA.