Everyone can just go ahead and issue their apologies to Jon Gruden now.

It was so easy to poke fun at Gruden last season, to say the game had passed him by, when he traded away pass rusher Khalil Mack and wide receiver Amari Cooper and the Oakland Raiders went 4-12 in Gruden’s return to coaching after he left the “Monday Night Football” broadcast booth.

The merits of those moves still can be debated. But Gruden has provided justification for his roster reshaping and has demonstrated to everyone that he still can coach. Year 2 of his comeback is going far, far better than Year 1 did. The Raiders, shockingly, are playoff contenders after nudging their record above .500 by beating the Los Angeles Chargers, 26-24, in dramatic fashion Thursday night in Oakland.

Rookie tailback Josh Jacobs’s 18-yard touchdown run with just over a minute remaining won it for the Raiders. Kicker Daniel Carlson missed the extra point but the Raiders held on when Chargers quarterback Philip Rivers threw his third interception of the night. Rivers had put the Chargers in front with a touchdown pass to running back Austin Ekeler with just more than four minutes remaining.

“I just love this team,” Raiders quarterback Derek Carr told Fox after the game. “I love this organization so much. I get emotional talking about it because I’ve been through so many highs and lows in this place. These fans have stuck behind me the whole way and it’s a lot of fun to win in front of them. ... To go down there in a two-minute drive and win the game on a run play, I just love that for our offensive line.”

The Raiders, at 5-4 and with a favorable remaining schedule, are a playoff contender in the AFC. They’re a game behind the first-place Kansas City Chiefs in the AFC West and in the thick of the wild-card chase. They’re a half-game behind the Indianapolis Colts, who are 5-3, for the second wild-card spot.

“We’ve got a lot of young guys so I tell them to just pump the brakes a little bit,” Carr said. “This is my sixth year. I’ve only been [to the playoffs] once and I didn’t get to play because I broke my ankle. So I tell them, ‘Let’s pump our brakes and let’s just do our job.’ That’s all we need to focus on right now. But it does feel good to be in the hunt. We’re playing games that matter, just like tonight. That’s what you want in November is you’re playing games that matter. We can set ourselves up. But we’ve got seven more games to go.”

The Raiders still have games left against the Cincinnati Bengals, New York Jets, Tennessee Titans, Jacksonville Jaguars and Denver Broncos, all sub-.500 teams. A 10-6 record is not out of the question. That would be quite a one-year turnaround orchestrated by Gruden, who savored Thursday night’s victory by celebrating with fans seated alongside the field. The franchise might be Las Vegas-bound. But Gruden clearly appreciates Oakland.

“I was really proud of our team,” Gruden said at his postgame news conference.

Jacobs told reporters in the Raiders’ postgame locker room: “This team is a lot better than we get credit for. And I think you see that now. I mean, we’re starting to put the pieces together. So it’s gonna be fun and interesting to see how we go on this little stretch and see how we do next week.”

Things didn’t look all that promising for the Raiders when they released wide receiver Antonio Brown just before the season. He’d been the team’s big-splash offseason acquisition, obtained in a trade with the Pittsburgh Steelers. But Brown never played a game for the Raiders, missing time because of injuries to his feet suffered while undergoing cryotherapy treatments and because of his two failed grievances against the NFL seeking to be allowed to wear a helmet not up to the league’s safety standards.

Brown requested his release after being fined for a practice-field verbal confrontation with General Manager Mike Mayock. Gruden and the Raiders again looked overmatched by the trials of the modern-day NFL.

And yet the Raiders have emerged with a greatly improved team. Carr is thriving under Gruden. Jacobs is a candidate for NFL offensive rookie of the year. The Raiders have been able to overcome the struggles of a defense that lost linebacker Vontaze Burfict to a rest-of-the-season suspension by the league for an illegal hit. Gruden and Mayock have assembled a roster full of what safety Erik Harris called “effort guys and character guys.”

The beleaguered Oakland defense did its part Thursday night as Harris had two early interceptions, one of which he returned for a touchdown. The Chargers, whose dropped to 4-6, rallied from a 10-0 deficit with a pair of second-quarter touchdowns.

The Raiders reclaimed the lead with Carr’s touchdown pass to fullback Alec Ingold 20 seconds before halftime. They led, 20-17, entering the final quarter and then came up with the big plays they needed down the stretch. Rivers’s final pass was intercepted by safety Karl Joseph with 20 seconds remaining.

“It’s a great feeling,” Harris said on the NFL Network’s postgame set. “On a short week, [give] credit to our coaches for getting us the game plan and preparing. I know they didn’t get a lot of sleep this week.”

Live updates:

4th Quarter

Chargers move back in front: The Chargers have reclaimed the lead in Oakland. Rivers threw a six-yard touchdown pass to Ekeler to cap an 80-yard drive. (Chargers 24, Raiders 20 with 4:02 left in the 4th quarter)

3rd Quarter

Chargers draw closer: It has been a kicking competition in the third quarter. The Chargers drew closer with a 27-yard field goal by Michael Badgley. (Raiders 20, Chargers 17 with 25 seconds left in the 3rd quarter)

Raiders miss FG: Carlson pulled a 53-yard field goal attempt wide left, keeping Oakland from adding to its lead. (Raiders 20, Chargers 14 with 7:56 left in the 3rd quarter)

Raiders add to lead: The Raiders got a touchdown just before halftime, and they added a field goal right after halftime. Carlson connected from 22 yards. (Raiders 20, Chargers 14 with 11:33 left in the 3rd quarter)

Halftime

Halftime in Oakland: It was an odd first half in Oakland in which the Chargers had the better of the play but dug themselves an early hole with two interceptions thrown by quarterback Philip Rivers to Raiders safety Erik Harris. The first of those led to a Raiders’ field goal. The second was returned 56 yards by Harris for a touchdown and a 10-0 lead for Oakland. The Chargers fought back from there and took the lead with a pair of second-quarter touchdowns, the first on Rivers’s pass to tight end Hunter Henry and the second on a run by tailback Melvin Gordon. The Gordon touchdown came just after Harris’s third interception of the half was nullified by an offside penalty. The Raiders finally got their offense moving and scored a touchdown 20 seconds before halftime on a pass from quarterback Derek Carr to fullback Alec Ingold. The Chargers had 16 first downs and 185 total yard in the half, to six first downs and 100 yards for the Raiders. Gordon had 71 first-half rushing yards for L.A. (Raiders 17, Chargers 14 at halftime)

2nd Quarter

Raiders back in front: The Oakland offense finally did something as the Raiders retook the lead with a nine-yard touchdown pass from Carr to Ingold. (Raiders 17, Chargers 14 with 20 seconds left in the 2nd quarter)

Chargers take lead: The Chargers have rebounded from the two early interceptions thrown by Rivers to take the lead in Oakland. Gordon provided a three-yard touchdown run on the play after a third interception of Rivers by Harris was negated by an offside penalty. Raiders defensive end Maxx Crosby was called for lining up in the neutral zone. (Chargers 14, Raiders 10 with 4:14 left in the 2nd quarter)

Chargers get TD: The Chargers are back in a game that they’re dominating statistically. Rivers threw a two-yard touchdown pass to Henry to cap a 16-play, 77-yard drive. The Chargers converted a fourth-and-one gamble at midfield along the way. They still trail despite 13 first downs and 135 total yards to one first down and 26 total yards for the Raiders. They’ve run 31 offensive plays to eight for Oakland. (Raiders 10, Chargers 7 with 8:24 left in the 2nd quarter)

1st Quarter

Rivers throws pick-six: The Chargers have had two possessions and Rivers has thrown two interceptions to Harris. This time, Harris went 56 yards for a touchdown on his return. Rivers released the pass as he was being hit low, and it went directly to Harris. The low hit wasn’t a penalty because the defender was blocked into Rivers’s lower legs, officials ruled. (Raiders 10, Chargers 0 with 6:02 left in the 1st quarter)

Rivers throws early pick, Raiders get FG: The Raiders have the early lead on a 40-yard field goal by kicker Daniel Carlson set up by a Rivers interception that ended the Chargers’ opening drive. Rivers’s throw sailed high over the head of intended receiver Keenan Allen and landed in the arms of Harris, who provided a 59-return to the Los Angeles 31-yard line. The Raiders had an interception of Rivers earlier in the drive negated by a defensive pass interference penalty, and Coach Jon Gruden lost an instant replay challenge contending that an incompletion thrown by Rivers should have been ruled a fumble. (Raiders 3, Chargers 0 with 8:01 left in the 1st quarter)

Read more NFL coverage: