DENVER — Peyton Manning’s stint as a backup didn’t last very long.

Manning replaced Brock Osweiler in the third quarter Sunday and led the Broncos a 27-20 win over the San Diego Chargers that clinched the top seed in the AFC playoffs for Denver.

“My gut told me to turn it over to him,” coach Gary Kubiak said.

Combined with New England’s loss at Miami, the Broncos (12-4) secured the No. 1 seed even as they head into the playoffs with a quarterback quandary on their hands.

Kubiak wouldn’t say who his starter will be in the playoffs, but insisted, “I don’t think we have uncertainty. ... We just find a way as a football team to be successful.”

The Chargers (4-12) wrapped up what might have been their final season representing San Diego as ownership tries to move the team to L.A.

The Broncos were facing the possibility of tumbling into the wild-card round because of Kansas City’s 10th consecutive win when Manning came to the rescue.

advertisement | advertise on newsday

Manning’s stat line — 5 for 9 for 59 yards, no TDs, no interceptions and one sack — belied the impact he had. He led Denver on four scoring drives in five possessions before he lined up in victory formation.

The last scoring drive lasted one play: a 23-yard run by Ronnie Hillman after emergency safety Shiloh Keo, who surrendered Antonio Gates’ go-ahead TD in the third quarter, picked off Philip Rivers’ errant pass with just under five minutes remaining.

Keo was in because starter Darian Stewart aggravated a pulled hamstring, one of two big injuries for Denver. The Broncos also lost Pro Bowl pass rusher DeMarcus Ware to a knee injury shortly after his first sack since returning from a bad back last month.

Hillman (15 for 117) and C.J. Anderson (15 for 95) combined for a season-best 210 yards and both scored a TD.

Manning was healthy enough to suit up for the first time in seven weeks. Previously, in street clothes he’d watched his longtime understudy either from the sideline or on TV while dealing with an injured left foot. This was Manning’s first game serving as a backup since his freshman year at Tennessee when he replaced an injured Todd Helton against Mississippi State on Sept. 24, 1994.

NFL videos

Because he didn’t start, Manning didn’t break the tie he holds with Brett Favre for most regular-season wins, 186. This one goes on Osweiler’s record, his fifth win in seven starts.

Manning led the Broncos to 10 quick points and a 17-12 lead on a 1-yard TD by Anderson and a field goal. But the league’s best defense frittered it away when Pro Bowl cornerback Aqib Talib let Tyrell Williams race past him for an 80-yard touchdown catch that put San Diego back on top 20-17 early in the fourth quarter.

Brandon McManus tied it with a 35-yard field goal.

On the game’s second play, Osweiler hit Demaryius Thomas for a 72-yard score. After that, he threw two interceptions, neither his fault; Denver turned the ball over five times, including on four consecutive possessions after its opening TD.

Osweiler was 14 of 22 for 232 yards, one TD and two interceptions — one went off receiver Jordan Norwood’s hands and on the other Osweiler’s arm was hit by a linebacker as he threw.

advertisement | advertise on newsday

His day was done after C.J. Anderson coughed up the ball at the Chargers 32, and Rivers capitalized with a 13-yard TD toss to Gates over Keo.

While Rivers was driving the Chargers to their first lead of the night, Manning was warming up on the sideline. A flustered Osweiler donned a Broncos stocking cap.

Manning hadn’t played since throwing four interceptions before being yanked on Nov. 15 in a 29-13 loss to Kansas City. But he showed no rust, completing both of his passes while leading the Broncos on an 80-yard go-ahead TD drive.

When Kubiak sent in Manning he also replaced struggling right tackle Michael Schofield with veteran Tyler Polumbus.