Updated

Lucas Harrell threw 98 pitches Sunday, and most were very good.

One of his best, though, was met by a better swing, and that's all it takes to beat the Houston Astros these days.

Pedro Alvarez's drive down the left field line for an opposite-field home run was one of just four hits allowed by Harrell in seven innings of the Houston Astros' 1-0 loss to the Pittsburgh Pirates.

"It was a sinker down and away," Harrell said of the Pirates' first ball out of the infield, with one out in the fifth. "I thought it was a really good pitch. He went down and got it. He's a big, strong guy and he slapped it out the other way. There's not much you can do about that."

Jeff Locke (4-1) allowed three hits over seven innings to win his fourth straight decision for Pittsburgh, which won for the eighth time in 10 games.

Through 6 1-3 innings, Alvarez's homer and a Travis Snider double were the only balls to leave the infield off Harrell (3-5), who had a single in a rare plate appearance for an American League pitcher.

"Today felt like the first game this season that I dominated both sides of the plate with my sinker," Harrell said. "(Catcher Carlos Corporan) did a great job with his homework. He had a really good game plan and I just followed along."

Pittsburgh's other chance at scoring came in the sixth, when Snider was thrown out at the plate by center fielder Brandon Barnes on a two-out single by Gaby Sanchez. The throw easily beat Snider, who put his shoulder into the chest of Corporan but could not jar the ball loose.

Harrell entered the game with the American League's fourth-best groundball-to-flyball ratio at 2.09, and pitched to form, inducing 13 groundouts.

"You could tell in the bullpen that he had a really good sinker today, so it was an easy game to call," Corporan said. "I just kept calling for sinkers because he was commanding it so well and they weren't hitting it. We probably threw a couple of curveballs and that was it. He pitched great."

So did Locke, who gave up one run or fewer for the fifth time in his past eight outings. He struck out four and walked three.

"'Pitched' is the imperative word," Pirates manager Clint Hurdle said of Locke. "He was behind a number of counts, his first-pitch strikes were below 50 percent ... but that being said, he didn't give up anything. He was able to put a foot down, get balls on the ground when we needed them."

In his past six outings, Locke has allowed 21 hits and seven earned runs over 37 innings (1.70 ERA). Despite allowing the leadoff man to reach four times, Locke permitted a runner to reach second base only once.

"There were some pitches early on that were real good pitches that I felt I had real good command of, but there were times in the game that I fell behind 1-0, 2-0 and put them in some pretty good hitter's counts," Locke said. "But I was able to make pitches and use the defense."

The notoriously streaky Alvarez pushed his average above .200 for just the second time since the second game of the season. His eighth home run came on the first pitch.

Alvarez's most recent homer was Friday — a titanic shot that reached the Allegheny River. Hurdle quipped that his third baseman followed up arguably his longest career home run with perhaps his shortest.

Off to their best 44-game start since 1991, the Pirates (26-18) have the National League's third-best record. They won despite the absence of outfielder Andrew McCutchen, who was a late scratch because of soreness in his right knee.

A day after his 13-game scoreless streak came to an end, Mark Melancon worked a perfect eighth and Jason Grilli finished with a 1-2-3 ninth for his majors-leading 17th save.

The Astros, who won in 11 innings Saturday night, did not have an extra-base hit.

"Their guy (Locke) did a good job," Houston manager Bo Porter said. "He changed speeds, pitched to both sides of the plate and kept us away from the barrel. Sometimes you've got to tip your cap and give credit to the other guy."

NOTES: Astros SS Ronny Cedeno was scratched from the lineup late Sunday morning because of a sinus infection. ... Houston has won three of its 11 series played this season while Pittsburgh is 8-2-2 in its past 12 series. ... The Pirates are off Monday but then play on 16 consecutive days. They open up a three-game series against the Chicago Cubs at PNC Park on Tuesday. ... Astros LHP Dallas Keuchel will make his third start of the season in the opener of a three-game series in Kansas City on Monday.