The rookie quarterback Jarrett Stidham bolstered his bid to be Tom Brady’s backup by throwing two touchdown passes for New England before the Giants scored on the final play for a 31-29 victory over the Patriots on Thursday night in Massachusetts.

Stidham, a fourth-round draft pick from Auburn, threw both of his touchdowns to Demaryius Thomas — for 35 and 3 yards. He played the entire night and saw most of the preseason game action in a competition with Brian Hoyer if New England (3-1) decides to keep only two quarterbacks. He went 18 of 28 for 225 yards against the Giants and also rushed for 50 yards.

Sidelined with a broken left thumb until Thursday, Patriots receiver Julian Edelman caught a 20-yard pass on the first series and got up looking at the same hand. He was met on the sideline by a trainer and stayed there chatting with Brady. He remained on the sideline the rest of the game.

Daniel Jones, the sixth overall pick by the Giants (4-0), started the game and was 4 of 4 for 47 yards before Alex Tanney and Kyle Lauletta played the rest of the game. Tanney and Lauletta each threw a touchdown pass as the Giants rallied from a 29-10 deficit. Tanney was also intercepted twice.