Jayson Werth gets a fist-bump from teammate Jerry Hairston Jr. after launching a three-run home run in the fifth inning of Tuesday’s win. (John Bazemore/AP)

The Washington Nationals finally found the offensive breakthrough they had been waiting for Tuesday night, which in the end mattered more than they hoped it would. They scored more runs in a game than they had in three weeks, and then they ensured, to their temporary horror, they needed every last one.

The Nationals carried a six-run lead over the Atlanta Braves into the eighth inning before escaping with a 7-6 victory at Turner Field. They built their lead on three-run home runs by Laynce Nix and Jayson Werth, who hit his first homer with a man on base this season. They squandered almost all of it with an eighth-inning meltdown. In the end, Drew Storen converted his eighth save — but not without a flyout to the warning track — and preserved the 100th victory of starter Jason Marquis’s career.

“Every now and then, you got to have a little margin for error,” Manager Jim Riggleman said. “Tonight we did. And it’s a good thing.”

The Nationals had last scored at least seven runs in a game April 20, and they did not figure to do it against Tim Hudson, the pitcher who had dominated them like no other. In 19 previous starts against the Nationals, he had an 11-2 record with a 1.88 ERA. In his last start, he pitched a shutout. The Nationals had been shut out Sunday for the fourth time this year. They kept saying their offense would break out, but Tuesday did not seem a likely occasion.

Then they did, in a way. They managed five hits, but smashed several line drives directly at fielders. They also received help from two Braves errors — four of Hudson’s runs were unearned. Their season average and on-base percentage, both ghastly entering the night, actually dropped to .222 and .293. But Werth and Nix delivered in crucial spots, and they aren’t giving the runs back.

“We got a few breaks,” Riggleman said, “and then we got two huge hits.”

With two outs in the fourth, Adam LaRoche reached on a single, first ruled an error, off first baseman Freddie Freeman’s glove. Wilson Ramos followed with a drive that center fielder Nate McLouth dropped.

“We’re a team that has to minimalize our mistakes,” Marquis said, “and capi­tal­ize on other team’s mistakes.”

Nix ensured the Braves would pay. With two strikes, he guessed Hudson would stray his pattern of pitching him inside. But when Hudson came back with another inside sinker, Nix stayed in position and “I was able to drop my barrel on it,” he said.

That’s one way to put it. Nix detonated a home run to left that landed some 430 feet from home plate. “He’s a pretty strong individual,” Werth said.

When Werth walked to the plate in the fifth, he had already flashed the frustration that had come with a month of waiting, for him and the rest of the Nationals, to halt their slump. In his first at-bat, Werth had drilled a one-hopper directly at the shortstop only to start a double play. When Werth returned to the dugout, he tore off his helmet and spiked it with two hands.

“I chuck my helmet all the time,” Werth said. “I just don’t like hitting balls at the shortstop. It wasn’t a matter of anything else other than that.”

With two runners on and two outs in the fifth, Werth had an opportunity to deliver a clutch hit, the thing that had been so elusive for him, owing to both a lack of chances and his own deficiencies. He worked a 2-1 count, and Hudson threw him an inside, 81-mph change-up.

“A month ago, I would have swung and missed,” Werth said. “Three weeks ago, I probably would have hooked it foul. A week ago, I would have hit it to the third baseman.”

Tuesday, Werth stayed back and then turned on the pitch, blasting a line drive over the left field fence to put the Nationals up, 7-1.

It was seemingly an insurmountable lead, but not for a team apparently terrified of prosperity, a team that hasn’t won a game by more than four runs all season. After Marquis yielded two one-out hits in the eighth, Sean Burnett allowed both batters he faced to reach. Riggleman summoned Tyler Clippard, his safety blanket in the toughest situations. With two runners on, Dan Uggla vaporized one of Clippard’s trademark high fastballs, a homer that, stunningly, made it 7-6.

“For a while there,” Riggleman said, “it was scary.”

The Braves would come no closer. Storen retired all three batters he faced in the ninth, his major-league-leading 17th scoreless inning, despite the fly ball by pinch hitter Brooks Conrad that pushed Roger Bernadina to the wall. Storen has converted all eight of his save chances, and his 0.46 ERA is best in the majors among pitchers with at least 18 innings.

“I’m just happy with my approach, really,” Storen said. “I’m feel like I’m doing the right thing sticking to a routine and not trying to do too much. That’s kind of where I got in trouble last year.”

In the end, the Nationals could revel in their third win in their past four games against NL East opponents. For one night, it didn’t matter that they used their margin of error, only that they had created it in the first place.