DETROIT — Buffalo’s Dan Carpenter did what Detroit’s Alex Henery couldn’t: The Bills kicker managed to split the uprights.

Carpenter hit a 58-yard field goal with 4 seconds remaining, sealing a come-from-behind 17-14 win over the Lions on Sunday afternoon.

Carpenter’s field goal came 17 seconds after Henery missed his third attempt, a 50-yarder that sailed wide left. Henery hit the right upright from 50 yards and fluttered a 47 yarder wide left on consecutive possessions in the third quarter.

Carpenter was good on three of four field-goal attempts. He clanked a 50-yarder off the left upright midway through the third quarter.

The Bills (3-2) snapped a two-game skid in Kyle Orton’s debut as Buffalo’s starter. And their defense had six sacks in delivering coordinator Jim Schwartz a win in his return to Detroit after being fired as the Lions head coach last season.

Orton, a 10-year journeyman, went 30-of-43 for 308 yards with a touchdown and an interception.

Orton set up the decisive score by hitting rookie Sammy Watkins over the middle for a 20-yard gain.

The ball was thrown behind Watkins, but he reached back with his right hand, tipping the ball forward and making the grab.

The Lions (3-2) squandered a 14-0 lead, dropped to 2-1 at home and also several key regulars.

Receiver Calvin Johnson did not return after aggravating a right ankle injury in the first minute of the third quarter.

And starting running back Reggie Bush didn’t finish the game after also hurting his ankle.

The Lions entered the game already missing running backs Joique Bell (concussion) and Theo Riddick (hamstring).

Golden Tate picked up the slack with seven catches for 134 yards and a 9-yard touchdown catch. The Lions defense assisted the offense with cornerback Rashean Mathis returning an Orton interception 41 yards for a score.

Quarterback Matthew Stafford went 18-of-31 for 221 yards with a touchdown and interception.

The Bills defense proved dominant in a matchup of among the NFL’s best units.

Buffalo limited the Lions to 263 yards offense and stopped them on 10 of 11 third-down opportunities. Marcell Dareus led the way with a career-best three-sack performance.

With Buffalo down 14-6, Orton capped nine-play 72-yard drive with a 2-yard pass to tight end Chris Gragg. Running back Fred Jackson then tied the game by running the ball in on two-point conversion.

Detroit had several opportunities to pull out the victory. That included their final full possession that began with 1:02 left.

Backed up at Detroit’s 11, Stafford hit Tate in stride on a slant to the left. Tate had a step on defender Nickell Robey and then beat safety Aaron Williams to the sideline for a 55-yard gain.

The drive stalled at the Bills 32, when Tate gained a yard by catching a tipped pass.

Out came Henery, who was signed two weeks ago to take over for rookie Nate Freese, who was having accuracy issues of his own. Lined up at the 40, Henery hit the ball solidly, but slapped his helmet in frustration in watching the kick just sale wide of the left upright.

The Lions appeared to take control by scoring twice in a span of 81 seconds spanning the first and second quarters.

Tate opened the scoring with a 9-yard catch with 5 seconds left in the first quarter. Four plays later, Mathis returned Kyle Orton’s interception 41 yards for a score.