The Redskins beat Dallas, 20-17, on Sunday, with the winning points scored by linebacker Preston Smith on a fumble return. (Ricky Carioti/The Washington Post)

The Washington Redskins have lived this season on the thinnest of margins, so it makes sense that they would win Sunday by the slightest nudge of the nose of the ball.

Staring at disaster, about to blow a 10-point lead in the final 4:55 of the game against their bitter rivals, the Dallas Cowboys, the Redskins found a miracle in an official’s whistle and a rarely called mistake.

Dallas’s long snapper, L.P. Ladouceur, moved the ball ever so slightly, causing Washington defensive lineman Daron Payne to jump offside. Long snappers cannot do that on field goal attempts, although it is a foul that is not usually flagged. Ladouceur, considered one of the NFL’s best long snappers, said he had never been called for that penalty in his 14-year career.

The penalty pushed Brett ­Maher’s game-tying attempt, at the end of regulation, from 47 yards to 52. Even though his foot struck the ball well, the kick curled left at the last second in a stiff autumn breeze, smacking the left goal post and dropping harmlessly to the ground.

A near-sellout crowd at FedEx Field screamed. The scoreboard said the Redskins’ 20-17 victory was complete, and a sea of Washington players raced across the field, celebrating a win that keeps them in first place in the NFC East at 4-2.

“It’s a lot harder to kick five yards farther back,” said Redskins linebacker Zach Vigil, who was on the field for the final play. “That ball didn’t curl left until the last second.”

Redskins running back Kapri Bibbs finds the end zone in the first quarter. (Ricky Carioti/The Washington Post)

It was a surprise to have that penalty call be the deciding factor in a victory over Washington’s most-hated rival. But then again, it was that kind of a day for the Redskins.

As they have all season, they had to grind and fight and claw their way to a win. They have been a puzzling group — close and confident — and yet they have followed stirring victories with odd defeats in an agonizing pattern.

“We can be as great as we want or as bad as we want,” defensive end Jonathan Allen said, shaking his head. “We can win every game or we can lose every game.”

On Sunday, the Redskins were both great and bad. They came into the game without two of their starting wide receivers, Paul Richardson Jr. and Jamison Crowder, as well as running back Chris Thompson — who is critical to their offensive success. And yet they improvised as they have for much of this season, handing the ball 24 times to running back Adrian Peterson, who gained 99 yards.

Cowboys kicker Brett Maher, left, is comforted by holder Chris Jones as Redskins defensive back Greg Stroman (37) and teammate Jehu Chesson celebrate after Maher missed a potential tying field goal on the game’s final play. (John McDonnell/The Washington Post)

They turned in a well-executed first-quarter touchdown when Thompson’s replacement, Kapri Bibbs, took a short screen pass from quarterback Alex Smith, danced past a strong block from guard Brandon Scherff and ran untouched for a 23-yard score that gave them a 7-0 lead.

But they also befuddled, with Smith missing receivers on critical throws, stalling on several promising drives and forcing them to kick two field goals when they had the ball inside the Dallas 10-yard line in the second half. What could have been a blowout was a nail-biter.

Coach Jay Gruden said he didn’t want to nitpick what happened in the third quarter after an inspiring victory, and yet Smith threw for just 178 yards.

In the end, the Redskins had to rely on their defense to win — something they are doing more and more as the season has worn on. Last year, the Redskins were last in the NFL against the run, and several of their defensive players — including Allen — have said that statistic enraged them. This past week, several players said, defensive line coach Jim Tomsula challenged them to stop Cowboys running back Ezekiel Elliott, Dallas’s most explosive player.

“That was the game plan: Stop 21 [Elliott’s number],” safety D.J. Swearinger said. “Let [quarterback] Dak Prescott beat us.

“Which he almost did,” Swearinger added.

The Redskins did what Tomsula demanded. They stopped Elliott, who had just 33 yards on 15 rushes. As a result, they stifled the Cowboys’ offense for most of the game, building a 13-10 lead, and they had Dallas pinned on its 10-yard line with barely more than five minutes to play.

Desperate to make something happen on a day when little had, Prescott backed up to his goal line to throw and was hit by Washington linebacker Ryan Kerrigan, who forced the ball from his hands. Linebacker Preston Smith picked up the ball and took one step for a one-yard touchdown that seemed to put the game out of reach at 20-10.

But instead of finishing off Dallas, Washington let Prescott quickly move downfield on a 12-play, 79-yard drive that led to a touchdown when Prescott pushed over the goal line from a yard out to make the score 20-17 with 1:37 left. And instead of running out the clock, the Redskins only gained seven yards in the next 28 seconds, giving the ball back to Prescott for one last drive. When Prescott turned the game over to Maher with three seconds left, the Cowboys should have been looking ahead to overtime.

That’s when Ladouceur moved the ball ever so slightly. “I saw something move,” Payne later said. The whistle blew, the subsequent kick missed, and the Redskins got to spend another week in first place in the NFC East.

“It’s great to beat Dallas; that’s all I care about,” Gruden said. “There’s a lot of things you think about. We could have done this. We could have done that. We could have put them away here. But at the end of the day, the only objective was to win the football game.”

Which is the way the Redskins have won four of their first six games this year — by stopping the other team’s best player, riding Peterson’s 33-year-old legs and holding on for dear life.

“They balled,” Gruden said.

And by the slightest movement of the nose of the ball, they won.