FOXBOROUGH, Mass. — Just when you thought the New England Patriots season couldn’t get any whackier, this happens.

The Patriots wiped out over 58 minutes of ineptitude Sunday afternoon as Tom Brady threw two touchdown passes in the final 64 seconds as New England stunned the Cleveland Browns 27-26 at Gillette Stadium.

With the Pats trailing 26-14 with 2:43 left, Brady drove the Patriots in for a 2-yard touchdown pass to Julian Edelman with 1:04 left. Stephen Gostkowski kicked the PAT. Then Kyle Arrington recovered an onside kick.

Aided by a controversial pass interference call against Cleveland’s Leon McFadden in the end zone against Josh Boyce, the Patriots scored again as Brady rolled right and found Danny Amendola in the end zone with 31 seconds left.

Billy Cundiff missed a 58-yard field-goal attempt on the game’s last play.

The Patriots played spiritless ball for most of the day and may have lost their biggest offensive weapon when tight end Rob Gronkowski suffered a leg injury with 8:27 left in the third quarter. Gronkowski had made a 21-yard catch when Cleveland defensive back T.J. Ward hit his right knee.

Gronkowski went down, slammed his fists into the ground and was carted off the field.

The Patriots trailed 12-0 at the time.

Gostkowski hit a 33-yard field goal but on the first play after the kickoff, Campbell threw an 80-yard touchdown pass to Josh Gordon. Gordon ran a slant from the left, stiff-armed Aqib Talib, then sprinted away, Talib giving up at the Patriots’ 30.

That made it 19-3.

New England got within 19-14. Shane Vereen scored a 6-yard rushing touchdown and Brady threw a 2-point conversion to Julian Edelman, who Gronk-spiked the ball. Then Gostkowski hit a 50-yard field goal with 5:43 remaining.

Cleveland led 6-0 at the half on two field goals by Cundiff, a 43-yarder in the first quarter and a 37-yarder in the second.