Right fielder Jayson Werth winds up on the ground while fielding Humberto Quintero’s leadoff single in the 11th inning. Quintero came around to score the winning run as Houston beat Washington despite a two-run homer from Werth in the sixth inning. (Thomas B. Shea/Getty Images)

Jayson Werth flicked away his black bat and stared for a moment at the ball he had sent soaring through the air, a small luxury with which he’d become unfamiliar. More than a month had passed since his last home run. Fans at Nationals Park have booed him. One District bar is pricing discounted beer in relation to his shrinking batting average. How low would he go?

Wednesday afternoon, in the Washington Nationals’ walk-off, 3-2 loss to the Houston Astros at Minute Maid Park, Werth may have put the worst behind him. He went 3 for 5 with a two-run home run and two doubles, ending a 105-at-bat drought without a homer by blasting a first-pitch sinker to left against former teammate Brett Myers in the sixth inning.

But the good feelings from Werth’s breakout dissolved suddenly in the 11th inning, when the Astros used three soft singles, the last one by pinch-hitter Jason Michaels, to form a game-winning rally against Nationals reliever Todd Coffey.

The bitter ending gave the Astros, the team with baseball’s worst record at 33-65, the series victory over the Nationals, who dropped to two games below .500. They came here hoping to get well after a brutal loss Sunday in Atlanta. Instead, they lost two more one-run games against the Astros, who hadn’t won a home series since May 25. The Nationals expected better.

“For sure,” said reliever Tyler Clippard, who escaped from a bases-loaded, one-out jam in the eighth. “We needed to win the series after the tough loss in Atlanta. But you know what, they played us really strongly. We weren’t good enough today.”

Livan Hernandez allowed two runs in six innings, and, as the Nationals got no hits from the seventh through the 10th, Manager Davey Johnson cycled through three relievers who kept the score tied at 2 until he summoned Coffey for the 11th inning. In a 7-6 loss Tuesday, Coffey had allowed the Astros to tack on the run that prevented the Nationals from tying the game.

Wednesday, he had another chance. Humberto Quinerto led off with a bloop single to right. With one out, Michael Bourn hit a slow roller that sneaked past Coffey and into center field. Up came Michaels. Coffey threw him an 0-1 slider down and away, hoping for either a groundball to second base or a swing-and-miss. Coffey executed the pitch how he wanted.

“From my perspective out there, I thought it was a good pitch,” Coffey said. “But honestly, any pitch that gets a hit is a bad pitch.”

Michaels flared it into center field. The Astros celebrated at home plate as Coffey walked slowly off the field. “That’s two nights in a row that I really let the team down,” he said. “It falls on my shoulders. Nobody feels as bad as I do. It fell on me tonight, and I dropped the ball for us.”

Werth gave the Nationals a chance to take the lead in the top of the 11th, when he smoked a double to center off reliever Wilton Lopez. Though he was stranded, it gave him his first game with three extra-base hits as a National.

The Nationals envisioned these kinds of games out of Werth when they handed him a seven-year, $126 million contract in December. Werth and several teammates insisted his mere presence had helped the Nationals, but he has been a disappointment with a bat in his hand.

Entering Tuesday, Werth had hit .155 with a .292 on-base percentage and a .236 slugging percentage since June 1. His batting average for the season dropped to .210 at its lowest point. He had not drilled two extra-base hits in the same game since May 20. Duffy’s Irish Pub is touting 16-ounce cans of beer at the price of Werth’s batting average, one penny per point.

Werth, though, after two months jam-packed with groundouts, infield popups and strikeouts, had shown recent signs of progress. He hit several line drives that found gloves in Atlanta’s outfield over the weekend. Tuesday night, he reached base three times and ripped a line-drive single to left.

“The biggest thing is, he’s starting to feel really comfortable in the box,” hitting coach Rick Eckstein said of Werth. “He’s been fighting to break a habit that he’s wanted to break.The last couple of games, he’s really been more consistent with that. . . . He’s really controlling his body and ultimately controlling his at-bats.

In his second at-bat on Wednesday, Werth did something rare, for him at least: He swung at the first pitch. In 406 plate appearances this season before Tuesday, Werth had swung at the first pitch 49 times. Only 11 major leaguers had been more selective on the first pitch.

“That’s something we have sat down and talked about,” Eckstein said. “In certain situations, if you happen to have a good hunch as to what you’re looking for, don’t let them get that first strike over. Put that seed in their head.”

Wednesday, it worked. In the fourth inning, Werth ripped Myers’s first-pitch fastball off the fence in center field, almost directly off the 404-foot mark on the fence. In his next at-bat, he swung at the first pitch again. Left field at Minute Maid Park has yielded many cheap home runs, but Werth’s shot in the sixth was not one of them. Left fielder Carlos Lee did not bother to move as the ball soared over his head, over the seats and off the tan back wall of the stadium to tie the score at 2.

Afterward, Werth declined to discuss his outburst — “I don’t feel like talking about it,” he said. He did diagnose how the Nationals are doing just enough to lose, even against the worst team in the majors. In 19 games under Johnson, the Nationals have played 13 one-run games and lost seven of those.

“It seems like all year, we’re not matching up,” Werth said. “If we pitch, we don’t hit. You hope you match up. That’s how you win games. In the second half, we’re going to have to hit and we’re going to have to pitch. Everybody in here wants to play in the postseason. I think this team has a chance to do that. We just got to match up.”