Late Wednesday night, as the Washington Nationals reached their most perilous moment in weeks, a foul ball rolled to Jayson Werth in the on-deck circle at Citizens Bank Park. In his former home, a place that welcomes old heroes back with raging jeers, Werth injected one more slice of drama into a night that lacked none.

The out-of-town scoreboard had delivered bad news. The Philadelphia Phillies’ go-ahead run, hours after the Nationals had taken a commanding lead, had died on the warning track. The Nationals’ firm control of the National League East, six months in the making, had begun to teeter.

And then Werth snagged the ball and faked a toss to a fan behind the Nationals’ dugout. He enlarged the already sizable target he wears every time he sets foot in this city, and then he delivered the blow that stabilized the Nationals’ 8-4 victory over the Phillies, a two-out, two-RBI single that rolled through the infield and sliced through a cascade of boos.

“I was so excited for him,” Bryce Harper said. “With these fans going crazy, booing him, telling him he [stinks] and whatnot, they don’t know what they’re missing. He’s an unbelievable ballplayer. He’s what gets us going.”

Harper, too, got the Nationals going. The day after he became an uncle — his sister, Brittany, gave birth to a baby boy — Harper started the Nationals’ early onslaught with a two-run homer, becoming the second teenager in baseball history to drill 20 home runs. They would take a 5-0 lead following homers from Ian Desmond and Kurt Suzuki in two innings off Kyle Kendrick.

“The kid got us going again,” said Desmond, who hit his 25th homer. “I’m just trying to distance myself from the 19-year-old. Nothing really amazes me. Regardless of all the home runs, the great throws, he impacts the baseball game every single day, whether it’s on the basepaths — everything.”

In the end, the Nationals could exhale, and then try to catch their breath in time for first pitch Thursday night. After they clobbered the Phillies early, they held on for dear life. John Lannan got his second win here in eight career starts, and the Nationals’ magic number dropped to four with seven games remaining, putting them a step closer to spraying champagne and sealing the division.

At one point Wednesday night, between Harper’s spark and Werth’s game-sealing, crowd-silencing single, the Nationals found perhaps the most harrowing moment of their season.

The Nationals entrusted the eighth inning to Tyler Clippard, the deposed closer who has been pitching like a husk of his typically dominant self. Chase Utley roped a leadoff double and Carlos Ruiz walked with one out, bringing the tying run to the plate. Domonic Brown crushed a deep drive to the warning track, a near-homer that scored Utley from third.

The Nationals led by only one run. The Braves were finishing off another win over the Miami Marlins, allowing for the possibility that the Nationals’ lead would drop to three games. Dari Ruf’s flare to right put runners on first and third with two down, the tying run one base away.

Pitching coach Steve McCatty visited Clippard on the mound. Clippard nodded as McCatty spoke, sweat dripping from his face, his eyes shifting toward the ground. Clippard fired a fastball past Frandsen for strike two. Two foul balls extended the at-bat. Clippard buzzed a chest-high, 93-mph fastball, and Frandsen foul-tipped it into Suzuki’s mitt.

The Nationals needed insurance runs. “This is a scary win,” Manager Davey Johnson said. “A scary ballpark.” Desmond sparked a rally in the ninth with a leadoff walk against reliever Justin De Fratus.

With one out, Werth came to the on-deck circle. A foul ball rolled toward him, and he turned to the fans behind the Nationals’ dugout. As he was about to flip the ball to a pack of children, he said, he thought back to earlier in the game. He’d tossed a ball into the right field stands, only for the ball to ripped out of a woman’s lap and thrown back on to the field.

“So in the ninth when I got the ball, I was going to flip the ball,” Werth said. “There was a group of kids. Behind the kids there were these unruly, middle-aged men that to me appeared to be snarling. It’s the ninth. Who knows? I kind of got the sense that maybe they were intoxicated.

“I was going to flip it to the kids, and then I thought, maybe I shouldn’t, because of the people right behind the innocent little children there. So I just flipped it in the dugout. Evidently, that rubbed some people the wrong way. After the events in right field, I felt it was better to maybe not throw it in the stands.”

The fake-out ball toss riled the fans. Werth dug in with two men in scoring position. Werth fouled off the first pitch as the crowd frothed. De Fratus fired the next pitch, a 94-mph fastball, under his chin. The crowd roared.

“I’ve played a lot of games here and I’m fairly aware of how the fans can be and how they do things around here,” Werth said. “I’m not the first guy to get booed, nor will I be the last. It makes for exciting baseball. These people are passionate. It’s just part of the game.”

Two pitches later, with two strikes, Werth smacked a single up the middle. Desmond and Suzuki raced home, and as he rounded first base Werth clapped hands as big as he could.

“I think he feeds off the boos,” Johnson said. “Sometimes, I think he gets too amped up here, but the boos get him real focused.”

The men in the Nationals dugout pushed forward, clapping along with Werth. He looked into the dugout and saw Michael Morse feeding “what seemed like the whole bag of balls” into the seats.

“I think he made up for it for me,” Werth said.

Werth insisted the emotion sprung from the importance of the hit in the midst of a playoff race, not from the crowd. “I was just happy to get the runs across,” Werth said. His teammates knew better.

“Jayson thrives on that kind of stuff,” Desmond said. “When it’s all stacked up against him, he comes through.”

For good measure, Harper added his ninth triple of the season and scored Werth, putting the Nationals ahead by four. They could relax as Drew Storen closed out the ninth, or least come as close to relaxing as a pennant race will let them.