OAKLAND, Calif. — Dallas kept its playoff hopes alive by the slimmest of margins.

Dak Prescott converted a fourth-down sneak by the width of an index card to set up Dan Bailey's go-ahead 19-yard field goal, and Derek Carr fumbled the ball inches from the goal line with 31 seconds left to give the Cowboys a 20-17 victory over the Oakland Raiders on Sunday night.

"We know where we're at, our season is on the line as far as going to the playoffs," tight end Jason Witten said. "It's good to just see us find a way to get the result that we did. ... Good to get lucky and see the football gods help you out a bit. I've certainly been on the other end of it over the course of my years."

The first key play came when Cowboys coach Jason Garrett decided to go for it on fourth-and-1 from his own 39 with about five minutes left in a tie game. Prescott ran into a pile that took officials time to untangle.

Referee Gene Steratore then called for the chains to come out, but even that wasn't clear. He then tried to slide what appeared to be an index card between the tip of the ball and the end of the chain. When the card didn't slide through, Steratore signalled a first down for Dallas (8-6). He said he had decided it was a first down before the odd measurement.

"The final decision was made visually. The card was used nothing more than a reaffirmation of what was visually done," he told a pool reporter. "My decision was visually done based on the look from the pole."

That explanation didn't satisfy Raiders coach Jack Del Rio.

"I had a different viewpoint. I saw air," Del Rio said. "It was pretty obvious. Again, they do the best they can with a tough job."

Prescott then hit Dez Bryant with a 40-yard pass that set up Bailey's short kick with 1:44 to play that gave the Cowboys the lead.

But the game was far from over. The Raiders (6-8) got a gift when Jourdan Lewis committed a 55-yard pass interference penalty on a fourth-and-10 from their own 30. Carr then scrambled on third-and-3 from the 8 and reached out for the end zone. But the ball came loose before crossing the goal line and went out of the end zone for a touchback that all but ended Oakland's playoff hopes. The Raiders are tied for ninth in the AFC.

"I tried to hold onto it," Carr said. "It wasn't like I didn't try. But there's obviously a lot of different things . throw it away, kick a field goal, run out of bounds. OK, cool. But in that moment I was just trying to win for my teammates."

Dallas is in a three-way tie for seventh place in the NFC, a half-game behind Atlanta for the final playoff spot. The Falcons beat the Cowboys head-to-head.

The Cowboys got their third straight win without suspended star running back Ezekiel Elliott, who returns from a six-game suspension next week. But Dallas' three straight losses at the start of the suspension created a hole the team is still trying to escape.

"We continue to scratch, we continue to claw," coach Jason Garrett said. "It wasn't our most perfect performance in any phase of our football team, but the fight was there."

FAKE IT OUT

The Cowboys took a risk in the third quarter on a fourth-and-11 from their own 24. Punter Chris Jones kept the ball and ran 24 yards for a first down. Dallas then drove down the field and took a 17-10 lead when Prescott ran in from 5 yards out and then was given a shower of drinks thrown by fans in the Black Hole.

MILESTONE THROW

Carr set up Oakland's first TD with a 32-yard scramble that was his longest run since his rookie year. That led to a 2-yard TD to Michael Crabtree that gave Carr 100 career touchdown passes. He joined Dan Marino, Peyton Manning, Russell Wilson and Andrew Luck as the only players with at least 100 TD passes in their first four years in the NFL. Carr added a second TD pass to Crabtree in the fourth quarter that tied the game at 17.

TAKE IT AWAY

Sean Smith intercepted two passes for the Raiders, doubling the team's total from the first 13 games. Smith got his first on the opening drive of the game and then added another just moments after Oakland got on the board for the first time. Bruce Irvin hit Prescott on the throw and Smith came up with the floater . He was initially given a TD return on the play but was ruled down by contact on replay and Oakland settled for a game-tying field goal from Giorgio Tavecchio.

INJURIES

The Raiders lost LT Donald Penn (foot) and DT Treyvon Hester (ankle) to injuries in the first half. ... Dallas LT Tyron Smith left in the second half with a knee injury.

UP NEXT

Cowboys: Host Seattle on Sunday.

Raiders: Visit Philadelphia on Dec. 25.

___

More AP NFL: https://pro32.ap.org and https://twitter.com/AP_NFL