Sep 20, 2015; Orchard Park, NY, USA; New England Patriots quarterback Tom Brady (12) drops to pass under pressure by Buffalo Bills defensive tackle Kyle Williams (95) during the second half at Ralph Wilson Stadium. Patriots beat the Bills 40-32. Mandatory Credit: Kevin Hoffman-USA TODAY Sports

The New England Patriots avenged their Week 4 loss to the Buffalo Bills with a 41-25 win in Sunday’s rematch in Orchard Park.

With the win, the Patriots move to 12-5 against Rex Ryan and move three games up on both the Bills and the Dolphins in the AFC East.

New England controlled most of the game, with Tom Brady nimbly dodging the Buffalo rush for the better part of the afternoon, picking apart the secondary. He finished 22 of 33 for 315 yards and four touchdowns to four different receivers.

It is the 25th career four-touchdown performance by Brady.

Rob Gronkowski led the Patriots in receiving, hauling in five catches for 109 yards and a touchdown, moving him into first place in franchise history with 69 scores, passing former Patriot great Stanley Morgan.

Buffalo looked to make a game of it in the first half, cutting the lead to 14-10 after New England had put up two quick touchdowns, threatening to slam the door early. The Patriot passing attacked proved too much for the Bills secondary, however, with Brady converting 6 of 8 third downs in the first half — two of which went for scores.

For Buffalo, the undisciplined play that has become the calling card of Rex Ryan coached teams reared its ugly head again. The Bills were penalized 12 times on the afternoon, often in key situations.

Missing two key offensive weapons, Bills quarterback Tyrod Taylor struggled through the air on the afternoon, completing on 19 of 38 passes for 183 yards. His lone bright spot on the afternoon was a 26-yard touchdown run in the third quarter, capping off a 13 play, 75-yard drive that saw Buffalo convert a fourth down deep in its own territory on a busted play when punter Colton Schmidt scampered for 16 yards after dropping the ball.

The Patriots answered, however, when LeGarrette Blount put New England back up by three scores with his 9th rushing touchdown on the year, scoring on a 1-yard run with 4:52 left in the game.

Pulling out of his slump, Patriots kicker Stephen Gostkowski was perfect on the day, connecting on all five of his PAT attempts and both of his field goal tries — the longest a 51-yard boot as time expired in the first half.

New England heads into its bye week relatively healthy with both a hammerlock on the division and, at worst, a one-game cushion in the AFC conference standings, pending the outcome of Sunday afternoon’s games.