The deal, which was first reported by Fox Sports, is for five years and $47.5 million, with $28.5 million guaranteed, a source told ESPN.com's Mike Reiss.
McCourty confirmed the agreement Sunday night on Comcast SportsNet.
"I'm blessed to say we had other teams that were interested, but I said all along that I knew in my heart that I wanted to be back in New England. But I also knew the business side of football, and I had to do what I had to do. I'm back, but I'd be lying if I said there wasn't possibilities over the last two days that I was going to be somewhere else. I'm happy it all worked out."
At one point as the negotiating process was winding down Sunday, McCourty told coach Bill Belichick it looked like he was ready to move on, a source told ESPN.com. McCourty and Belichick in fact had a phone conversation in which McCourty thanked him for a great five years with the franchise before he ultimately decided to stay with the team.
A first-round draft choice of the Patriots in 2010, selected 27th overall out of Rutgers, McCourty is a four-time team captain who quickly became one of the team's foundation players after signing a five-year, $10 million pact as a rookie.
McCourty, who will turn 28 in August, emerged as one of the NFL's best safeties despite entering the league as a cornerback. He made an in-season switch to safety in 2012, in part because of the team's struggles defending the big play that year, and has mostly played there since.
The combination of McCourty entering his prime years and ability to play both cornerback and safety made him one of the more highly sought-after free agents on the market this year. He's been durable, missing only three games over the first five years of his career, as well as productive (72 tackles, two interceptions, six passes defended in 2014).
Speaking at a community appearance in Lowell, Massachusetts, on Feb. 25, McCourty had expressed his desire to remain in New England.
McCourty's $9.5 million-per-year average ranks him as the second-highest-paid safety in the NFL, the figures coming in higher than ESPN's projected contract for him. This reflects a robust market for McCourty and how serious the other suitors were in their pursuit. It also reflects how the Patriots stepped up to make sure one of their own wouldn't get away by rewarding him with a very strong deal.
With McCourty in the fold, the focus now turns to cornerback Darrelle Revis.
This deal, coming together at the last moment when McCourty made it clear he was ready to move on, shouldn't prohibit the Patriots from making a strong push to also retain Revis.
ESPN.com Patriots reporter Mike Reiss contributed to this report.