Washington’s Jesus Flores slides into second with a fifth-inning double Tuesday in Houston. With the win, their fourth straight, the Nationals move to 24 games over .500 at 67-43 and take over the best record in the majors. (Pat Sullivan/AP)

HOUSTON — The ball went up, and when it came down the game would be over. Roger Bernadina crashed into the outfield fence and vanished, and when he returned to view the Washington Nationals would win or lose. Joy or deflation, relief or despair — it was the end.

The moment — two outs, a one-run lead and two Houston Astros runners headed home — promised to keep you up at night, too angry or too wired to sleep. Afterward, in their giddy clubhouse, one Nationals player would exclaim, to no one in particular, “My blood pressure!”

Bernadina, laying in the warning track dirt, held up the ball. His miracle, all-out catch had sealed the Nationals’ 3-2 victory in the 12th inning. Bernadina beamed as he rushed into the infield to high-five his joyous teammates. They had the most frayed nerves and, at 67-43, the best record in baseball.

They arrive at victory in the most difficult ways possible, but these Nationals have more fun that way. After Bernadina’s flying catch, Craig Stammen jumped up and down in the Nationals’ bullpen. Players streamed from the dugout pantomiming large, chomping jaws. Ian Desmond rushed to his locker and Tweeted Bernadina’s nickname: “Shaaaaaaaaaaaaaaaark!!!!!!!!!”

“He disappeared and came out holding the glove high,” Manager Davey Johnson said. “I said, ‘Man, this is great. Let’s get out of here.’ ”

Shortstop Danny Espinosa drove in the winning run with a single in the 12th, 10 innings after he produced the Nationals’ two other runs with an upper-deck homer. The Nationals’ offense had snapped to attention just in time to make something of Ross Detwiler’s second straight eye-opening start and five scoreless innings from their bullpen.

The Nationals’ offense had stagnated until Espinosa’s RBI single, which gave closer Tyler Clippard a lead to protect. Houston’s Steve Pearce lined a single off the tip of Cesar Izturis’s glove at second base in the bottom of the 12th. Clippard retired the next two batters. Carlos Corporan fouled-tipped a 3-2 fastball off Jesus Flores’s mitt. Clippard walked him with the next pitch, moving the tying run to second base.

Then Brett Wallace destroyed a 1-2 fastball to deep left-center. In the dugout, Johnson thought the ball was going to clear the fence for a game-winning homer. But Bernadina knew he had a chance. He read the ball off the bat and sprinted to his left. He could tell immediately he might collide with the fence.

“In that moment, you don’t think about it,” Bernadina said. “You just go for it.”

Left field at Minute Maid Park introduced tricky variables. Bernadina had to navigate the corner that juts out in left field, and also the columns of signage that stick out a few feet from the fence.

Between that signage is a chain-link fence that houses the visiting bullpen. As the ball soared to the outfield, Stammen realized the ball was coming at him. He screamed at Bernadina, “You’ve got room! You’ve got room!”

As Bernadina neared the fence, Corporan was closing in on third. If he didn’t catch the ball, the Nationals would lose. After a 100-foot sprint, Bernadina leapt into the wall, his glove in the air. Few players on the field could see him — at shortstop, Espinosa knew Bernadina had reached the ball, but not if he had held on.

“He caught it,” Stammen said. “And I was like, ‘OK, is he dead or alive?’ ”

Bernadina, on the ground, thrust his glove in the air. Stammen started jumping, a moment perfectly captured on the television broadcast. (“I know I’m going to get made fun of,” he said.) His teammates rushed from the dugout. Clippard lifted his arms and exhaled. Bernadina grinned. The Nationals had won.

“That game took forever,” Bernadina said. “We wanted to get out of here.”

Detwiler gave the Nationals ample opportunity for a rocking-chair victory against a hapless opponent that has now won four of its past 36 games, breezing through six scoreless innings after allowing a two-run homer to the third hitter he faced. But Washington’s offense was ice cold. In the first 11 innings, it managed four hits and struck out 13 times, seven times in innings eight through 11. The first six hitters in the Nationals’ lineup went a combined 0 for 25 with three walks and 11 strikeouts, four by Ryan Zimmerman.

Michael Morse changed all that when he led off the 12th. He smashed a line drive off Mickey Storey to center field that would have been a home run in 29 other parks, and perhaps the Polo Grounds, too. At Minute Maid Park, it came to rest on the berm at the foot of the center field fence, nearly 430 feet from home plate. A ball will not be harder hit this season without clearing an outfield wall.

As it stood, Morse had a double and extended his hitting streak to 16 games. New addition Izturis pinch-ran for Morse. Bernadina executed a sacrifice bunt, and Izturis moved up to third.

The infield encroached as Espinosa came to the plate. He worked the count to 2-2, sitting on one close two-strike pitch and fouling off another. In the second, he had a blasted a fastball from starter Jordan Lyles into the upper deck. Now, he had a more modest goal.

“Just put the ball in the play,” Espinosa said. “I need to put the ball in play right here, a groundball, whatever. Maybe hit a groundball and the guy will make an error, or Izturis will beat it, something. I’m just trying to put the ball in play at that point.”

He finally squibbed a curveball back up the middle. Once the slow roller snuck past Storey, the drawn-in fielders could only watch it dribble into to center field. Izturis scooted home, and the Nationals had the lead.

For consecutive nights, the Nationals have excuted an easy score with the highest degree of difficulty. They could have started their 10-game road trip with two breezy wins over the Astros. Instead they required extra innings, frayed nerves and antacid tablets, down to each final, amazing out.

“I told those boys to get a lot of rest,” Johnson said. “Because they’ll probably do the same thing tomorrow.”