Jerry Hairston (No. 15) finds a welcoming party at home plate after his grand slam put the finishing touches on the Nationals’ victory in Los Angeles. (Chris Pizzello/AP)

When he crossed home plate, John Lannan played it cool. His teammates in the Washington Nationals’ dugout may have erupted, fists in the air, laughing, awestruck and generally reacting as if a spaceship had landed in center field. Not Lannan. Even after he launched his first home run since he was a 15-year-old — chieved after four big league seasons left him with a double-digit batting average — Lannan trotted around the bases with a blank face.

“I knew if I laughed,” Lannan said afterward, “it would have just looked bad.”

The Nationals could have never guessed Lannan, by virtue of a two-run homer and a single, would become the hitting star of their 7-2 victory over the Los Angeles Dodgers at Dodger Stadium on Friday night. They do know they can rely on him when he’s standing on the mound. Along with his wildly improbable homer, Lannan allowed one earned run in 6 1 / 3 innings, almost single-handedly halting the Nationals’ losing skid at two games.

Jerry Hairston sealed it with a grand slam off Matt Guerrier in the ninth inning, a line drive to left field on a 3-2 fastball. Before Hairston’s game-clinching blast, Lannan had carried Washington.

Lannan’s newfound success at the plate sprung from nowhere — in his past two games, he is 4 for 6 with four RBI. His reliability on the mound is familiar. The Nationals have won 10 of the last 14 games Lannan has started, a span during which he has lowered his ERA from 5.09 to 3.51, which places in the top 20 in the National League. He is, solidly, their second-best starter.

He was, shockingly, their best offensive player Friday. When Lannan walked to the plate with two outs in the second inning and shorstop Ian Desmond on first base, he was a career .092 hitter, 18 hits in 195 at-bats. His first major league pitching coach, Randy St. Clair, told him it sounded as if in place of a bat, he used a wet newspaper.

It was not obvious, but Lannan has improved his hitting over the years. “He’s starting to get it,” Desmond said earlier this season, a claim obscured by Lannan starting the season 0 for 33. Lannan hit a homer in batting practice for the first time this year, and fellow pitchers started calling him “Longball” Lannan. A home run in game, although he did send a flyball to the warning track this season, still seemed out of the question.

After Lannan saw three pitches, Dodgers starter Hiroki Kuroda threw a 1-2 slider down and away. Lannan whacked it to right field, and Andre Ethier tracked it back to the warning track. He stopped and watched it fly over the fence, just to the left of the 360-foot marker. Ethier put his hands on his knees, apparently in disbelief.

He was not alone. The Nationals’ dugout exploded, a mixture of shock, amazement and jubilation. “Oh my God!” Livan Hernandez yelled, grabbing the brim of his cap with both hands.

Said Manager Davey Johnson: “[Pitching coach Steve] McCatty’s over there, you know, fainting.”

As Lannan finished his home run trot, Ivan Rodriguez aligned the Nationals on the dugout railing, away from the entrance by the top step. He frantically set up a time-honored baseball prank: the first career homer freeze-out.

“We gave him the silent treatment,” Hernandez said.

When Lannan walked back to the bench, the Nationals players bit their tongues, stifled smiles and ignored him. As Lannan stood alone and shoved his helmet in the cubbyhole, they stopped the act and mobbed him with high-fives and pats on the backside. It was all smiles by the bat rack.

“That’s all we talked about for about five straight innings down” in the bullpen, Sean Burnett said. “We were still in shock. We were going to call down from the bullpen and ask for a curtain call.”

Even after the game, Lannan’s homer remained the topic of choice. When reporters entered the Nationals clubhouse after the game, Tyler Clippard called over to them. “John Lannan hit a home run,” he said. “I don’t know if you guys saw that or not.”

A team employee had retrieved the ball for Lannan, and it sat on the top shelf of his locker, inscribed with “1st ML HR.” He had watched the replay twice. His phone had 18 text messages, all of them containing roughly the same sentiment: “I can’t believe it.”

“It’s kind of a blur right now,” Lannan said. “I’m still pretty shocked.”

With one swing, Lannan had raised his career slugging percentage 20 points, from.113 to .133. He became the third pitcher to homer for the Nationals since baseball returned to D.C., joining Ramon Ortiz and Hernandez.

He had also put the Nationals ahead 3-0, all the runs he would need. Lannan held the Dodgers to three hits and struck out six. He may have been affected by the excitement from the home run, walking two batters in the bottom of the second and four overall. But he limited the damage, even in tough spots not entirely of his own making.

The Dodgers scored two runs off him in the fourth, one them earned, the other directly attributed to the two errors Desmond committed in a span of three batters. Desmond’s fielding has improved tremendously this year compared to last, but the fourth inning provided an ugly flashback. After not making an error from May 5 through June 21, Desmond has seven in 23 starts since. (Friday, he helped make up for the gaffes by reaching base four times, with three walks and a single, and scoring two runs.)

Lannan started the fourth by walking Matt Kemp, and Juan Rivera followed with a double down the left field line. Juan Uribe chopped a pitch toward short, and Desmond charged it, leading to an awkward short hop. The ball scooted under his glove and into the outfield, allowing two runs to score and cutting the Nationals’ lead to 3-2.

After Lannan recorded the first out with an infield popup, he gave himself a chance to escape the inning quickly by inducing a grounder to short from Jamey Carroll. Desmond flubbed the transition, rolling the ball weakly to second baseman Danny Espinosa. Lannan worked around the jam in four pitches after the second error.

Lannan took partial responsibility for the miscues, saying that his wildness contributed to a decrease in defensive alertness behind him.

The errors were forgotten after Hairston’s blast in the ninth. He had entered as a pinch-hitter earlier, and when he came to bat with the bases loaded the Dodgers summoned Matt Gurrier. Hairston went ahead 3-0, then took one strike and fouled off another to run the count full. He sat on a fastball, and crushed it on a line to left field.

“There’s no way he wants to walk me there,” Hairston said. “Ninety-five percent of the time, he’s going to throw me a fastball. I just put a good swing on it.”

The Nationals scored their first run with a two-out rally in the first. Ryan Zimmerman ripped a single up the middle. Michael Morse followed with a line drive straight at Uribe at third base. He smashed the ball so hard it went deflected off — or maybe went through — Uribe’s glove and rolled deep enough to left field for him to scoot to second base. Zimmerman scored.

An inning later, Lannan would walk to the plate carrying a reputation as one of the easiest outs in baseball. Then he sent the ball screaming through the thick Southern California air, his first home run at any level in more than a decade. Somehow, he acted like he wasn’t surprised. Rest assured, he was.

“I think everybody was shocked,” he said.