The team did not disclose terms but the deal is to be a five-year deal, sources told ESPN's Adam Schefter.
Defensive tackle Alan Branch, meanwhile, has agreed to return to the Patriots on a two-year deal worth up to $12 million, and safety Duron Harmon is back on a four-year deal worth up to $20 million, according to ESPN sources.
The news of Branch's return was first reported by CSN New England.
Gilmore, 26, bounced back from a rocky start last season with the Buffalo Bills to become one of the NFL's best available free agents this spring.
After the Bills exercised Gilmore's $11.082 million fifth-year option in May for the 2016 season, the two sides failed to reach a long-term contract agreement before talks ended last summer. Gilmore made his negotiating position clear during training camp, saying he believed he was among the elite cornerbacks in the league.
The Bills chose not to use the franchise tag, as the $14.2 million price tag for cornerbacks was prohibitive.
The planned signing of Gilmore meant that free-agent cornerback Logan Ryan was not likely to return to New England, and his agents Thursday night announced that Ryan was joining the Tennessee Titans.
The future of Patriots cornerback Malcolm Butler, a restricted free agent, is also uncertain.
"The Patriots haven't approached Malcolm about his contract since last year, and anything that says he has been asking for the moon is completely false," Butler's agent, Derek Simpson, said Thursday night.
The 6-foot-6, 350-pound Branch, who is set to enter his 11th NFL season, is coming off arguably his best year ever. He played 60.1 percent of the defensive snaps in the regular season, which Bill Belichick highlighted as a significant increase and a reflection of Branch's being in good physical condition to handle the additional workload. Branch had played 39.6 percent of the defensive snaps in 2015.
At one point during the 2016 season, Belichick said Branch was the team's most consistent defensive tackle "by far," pointing to him as an example for younger players Malcom Brown (2015 first-round pick) and Vincent Valentine (2016 third-round pick) to follow.
Branch, who turned 32 in December, totaled 49 tackles with 1.5 sacks in the 2016 regular season. His ability to play a variety of techniques along the interior was valued by the coaching staff, as he helped control the line of scrimmage in the running game while pushing the pocket at times against the pass.
Gilmore's play over the first half of last season was lackluster. Pro Football Focus ranked him 82nd among NFL cornerbacks through the first eight weeks, and when Gilmore was part of coverage breakdowns in a Week 8 loss to the Patriots, then-coach Rex Ryan said Gilmore needed to return to fundamentals.
Gilmore turned in better performances over the second half of last season, snagging two interceptions in a Week 11 win over the Cincinnati Bengals and improving his PFF ranking to 61st among cornerbacks by the end of the season. Gilmore was rated as PFF's 14th-best cornerback in 2015.
He finished the 2016 season with a career-best five interceptions and earned his first Pro Bowl selection.
The 10th overall selection of the Bills in the 2012 draft, Gilmore has started 66 games in five seasons and has 14 career interceptions.
ESPN's Mike Rodak and Mike Reiss contributed to this report.