Josh Allen passed for 288 yards and two touchdowns and ran for another as the visiting Buffalo Bills remained unbeaten with a 30-23 victory over the Las Vegas Raiders on Sunday afternoon.

Allen, who completed 24 of 34 passes, left the game briefly late in the second quarter, grabbing at his left shoulder after completing a backhanded, left-handed shovel pass to Stefon Diggs. Diggs caught six passes for 115 yards and Devin Singletary rushed for 55 yards and a touchdown for Buffalo (4-0).

Derek Carr completed 32 of 44 passes for 311 yards and two touchdowns for Las Vegas (2-2), breaking the franchise record with 151 career touchdown passes. Darren Waller caught nine passes for 88 yards but also had a costly fumble. Josh Jacobs rushed for 48 yards on 15 carries and Daniel Carlson kicked three field goals (54, 39 and 25 yards) for the Raiders, who lost for the first time at Allegiant Stadium.

Buffalo jumped out to a 14-3 lead in the first half behind a pair of Allen touchdown passes, the first a 26-yarder to rookie Gabriel Davis and the second an 11-yarder to Cole Beasley, with both capping 75-yard drives. Beasley held on despite being flipped head-over-heels at the goal line by Raiders safety Lamarcus Joyner.

The Bills increased their lead to 17-6 on a 34-field goal by Tyler Bass but Las Vegas responded with a 75-yard, 11-play drive just before halftime capped by Carr’s 3-yard touchdown pass to Jason Witten to cut it to 17-13. It was Carr’s 150th career TD pass, tying the team record set by Kenny Stabler. It was also the 73rd career touchdown reception for Witten, and his first without the Dallas Cowboys.

Carlson’s 25-yard field goal capped an 11-play, 68-yard drive to open the second half and drew Las Vegas to within 17-16, but Buffalo answered with a 1-yard touchdown sneak by Allen on the first play of the fourth quarter to extend its lead to 23-16. The score, followed by a missed PAT by Bass, was set up by a 38-yard punt return by Andre Roberts and a highlight-reel 14-yard grab by John Brown at the goal line.

Buffalo then increased its lead to 30-16 on a 2-yard touchdown run by Singletary. The score came four plays after cornerback Josh Norman, playing in his first game with the Bills, punched the ball free from Waller at the Bills’ 32 and then recovered the fumble. On the ensuing play, Allen then connected with Diggs for a 49-yard completion.

The Raiders closed to within 30-23 when Carr hit Nelson Agholor with his record-setting 7-yard touchdown pass on fourth-and-1 with 1:29 remaining, but Buffalo recovered the ensuing onside kick and ran out the clock.