Washington’s Danny Espinosa is greeted at home by pinch runner Laynce Nix, who rode home on Espinosa’s two-run homer to right in the seventh inning. The blast snapped a tie and sent the Nationals to a 4-2 win over Pittsburgh. (Alex Brandon/Associated Press)

Monday afternoon, hours before he would walk to the plate for the night’s most crucial at-bat, Danny Espinosa joined several teammates for early batting practice. He needed to work out a mechanical kink in his left-handed swing that had pulled him into a slump and irked him for days. Friday, after an extra-inning loss, he grabbed a bat minutes from midnight and walked out of the Washington Nationals’ clubhouse to the batting cage.

“At times, it can probably be too much,” Espinosa said. “I feel like I need to be in there.”

When Espinosa strode to the plate Monday night, his batting average below .200, he busted his recent slump with one emphatic, left-handed swing. Espinosa’s two-run homer sent the Nationals to a 4-2 victory over the Pittsburgh Pirates and pulled the team within one game of .500. Espinosa’s blast ensured Cole Kimball’s first major league blip would not haunt the Nationals, preserved John Lannan’s 61 / 3 innings of two-run pitching and set up a high-wire ninth from Drew Storen, who notched his ninth save after bringing the go-ahead run to the plate with one out. In his rookie season, which followed a one-month September cameo last year, Espinosa has learned how demanding the rigors of the major leagues can be. He played exquisite defense at second base — “I’m still bringing something to the field every single day,” he said — but had begun to feel the weight of his slump. It had crept to 1 for 23 and, more broadly, 8 for 73.

“It’s tough,” Espinosa said. “Everybody says, ‘Everyone goes through it.’ But at some point, you go, ‘Well, how long does everybody go through it?’ At some point, it becomes, ‘I gotta get something going. I need to do something.’ ”

After Michael Morse singled with one out in the seventh, Espinosa walked to the plate with left-handed starter Paul Maholm on the mount. In his first two at-bats, he had crushed a fly ball to the warning track in left field and ripped a line drive to center only to produce a pair of outs. “I had to laugh those off,” he said.

He hit those balls right-handed, but now Pirates Manager Clint Hurdle pulled Maholm in favor of right-hander Jose Ascanio. The move would force Espinosa, a switch-hitter, to hit from the left side, which the Pirates surely wanted.

“If I’m the manager of that team,” Nationals third baseman Jerry Hairston said, “he’s hitting left-handed.”

Espinosa’s slump had been built mostly on struggles as a left-handed batter. Before last night, Espinosa was 17 for 97 (.125) with 25 strikeouts against right-handed pitching. He began making an adjustment to his swing. Espinosa could not find the right timing for his leg kick, which he said made his swing long and late.

When Hurdle had called on Ascanio, Espinosa walked back to the dugout and switched helmets, angry inside. He feels his left-handed swing, despite his struggles, is at least as good as his right-handed stroke. “That put fuel in my tank,” he said.

Ascanio toed the rubber, kicked his leg and delivered a 89-mph change-up that darted low and inside. Espinosa, looking for a fastball, unleashed his sudden swing. As the ball rocketed to right field, Espinosa stood at the plate, his shoulders square to the outfield, and watched for a moment. He then dropped the bat and started trotting, watching as the ball landed deep in the Nationals’ bullpen.

“The first thought was, ‘I helped the team,’ ” Espinosa said. “The second thing was, ‘Bad idea bringing in the righty.’ ”

Espinosa did not consider himself extricated from the slump, but finally seeing his work reap dividends surely meant something to him.

“I knew I wasn’t going to stay in this,” Espinosa said. “And I’m not going to say I’m out of it 100 percent, because it was one hit. But my confidence up there, I feel better. I feel more comfortable. I feel like I’m going to carry this over.”

Lannan navigated through seven hits and four walks while allowing just two runs, only one of which scored with him on the mound. He came out for the seventh inning having thrown 94 pitches, and he promptly walked leadoff hitter Ronny Cedeno. After Cedeno moved to second on Maholm’s sacrifice, Manager Jim Riggleman called on Kimball.

Kimball jogged into his third game in three days. He had never pitched three days in a row in professional ball, but “I’ve been begging and begging and begging to get three days in a row for the last three years,” he said. “I’ll be good to go tomorrow, too. I’ve got a rubber arm.”

Said Hairston, “He’s the type of kid — and I say this in the most loving way possible — he may not be all there.”

Against Kimball, Andrew McCutchen roped a 94-mph fastball to the right-field corner, scoring Cedeno and tying the game. Even after he stranded McCutchen to keep the score tied, Kimball screamed an expletive on his way off the mound.

“If I come with a lead, I don’t want to leave with the win,” Kimball said. “I hate giving up other guys’ runs more than my own.”

Still, he had his first W. In the clubhouse, Lannan stuck with tradition slammed a shaving-cream pie in his face. The Nationals could celebrate thanks to Espinosa. He had defiantly broken his slump, and had lived up to his manager’s description of him.

Said Riggleman: “He’s a tough kid.”