PITTSBURGH -- The night after a long Pittsburgh Pirates winning streak ended, one of their starting pitchers extended one of his own.
Locke (8-1) was scored upon for the first time in four home starts but extended his unbeaten streak to 16 outings. Locke, who hasn't lost since his first start of the season, allowed two earned runs on seven hits and three walks over 5 2/3 innings.
"They're going to get their hits -- and I'm also going to make my pitches," Locke said. "I'm going to win some battles; they're going to win some battles. A night like tonight they're finding some holes and hitting the ball pretty hard at points, you've just got to try to stay consistent and don't teeter away from what you do well."
The Pirates took the lead with a four-run fifth punctuated by Alvarez's 21st home run.
Andrew McCutchen reached base five times, scoring twice for the Pirates (52-31), who have the majors' best record and had a nine-game winning streak snapped in the series opener Tuesday.
"I'll tell you what -- there's something special going on here," Locke said. "All the guys pull for each other every night. We're not out of a game, ever. And I think the Pirates of the past could get out of a game early, we'd kind of get down on ourselves a little bit and think that hill's too tall to climb. But nothing here these guys can't do."
Brown's two-run homer with two outs in the ninth pulled the Phillies within one, but Jason Grilli stuck out Young to seal his NL-best 28th save.
Philadelphia's John Lannan (1-3) fell to 1-5 in his career against the Pirates, getting tagged for four runs on 11 hits and three walks in five innings. Phillies manager Charlie Manuel said, "It definitely wasn't one of (Lannan's) better games."
Still, he kept Pittsburgh off the scoreboard through four. The Pirates left seven men on base in that stretch.
Pittsburgh loaded the bases with no outs in the second, but Locke struck out and Starling Marte bounced into a double play.
"I was battling all night, and I was able to pitch myself out of a lot of jams," Lannan said. "But then I made a bad pitch to Alvarez, and that was the difference in the game."
McCutchen, Sanchez and Martin hit consecutive one-out singles in the fifth, the latter driving in a run. Alvarez followed with his fourth home run over his past six games against the Phillies.
"I was just up there trying to be ready to hit and not really sitting on anything," Alvarez said. "I was just trying to go out there and put a good at-bat together."
Those runs erased an early deficit for the Pirates. When Ben Revere drove in Brown with a bloop single to left with two outs in the fourth, it snapped a 24-inning scoreless streak for Locke at PNC Park. That's the longest home shutout streak for a Pirates pitcher since Jerry Reuss did it for 34 innings in 1975.
Locke had his scheduled start bumped back a day when he was forced to warm up in the bullpen during the 14th inning of a win Sunday. He had three consecutive home starts in which he did not allow a run between May 14 and Wednesday.
"As much as anything, he's got a very good demeanor," Pittsburgh manager Clint Hurdle said. "There seems to be no panic, no urgency. He just continues to make pitches and focus on that pitch to that hitter."
Brown's home run off of Grilli snapped a 27 1-3-inning scoreless streak by the Pirates' bullpen. Brown has three home runs through nine games on Philadelphia's road trip and a team-high 22 on the season.
"I'd like to make the All-Star team; it'd be a great honor," the 25-year-old Brown said. "I'm not really thinking about that right now. I'm thinking about our team and how we can start winning some games."
Martin's second RBI came when he doubled in McCutchen in the sixth. ... Howard was not in the starting lineup for the second time in a four-game span. Howard, who snapped out of an 0-for-22 slump with two hits Tuesday, has been bothered by a sore left knee all season. He was walking gingerly after Tuesday's game, one in which he scored from first by sprinting on a double during the sixth inning. ... The Pirates activated OF Jose Tabata before the game and optioned RHP Brandon Cumpton to Triple-A Indianapolis. Cumpton was recalled to start Tuesday's game in lieu of Locke. ... Buoyed by thousands of Phillies fans who made the drive across the state, the announced paid crowd of 33,197 was the Pirates' eighth consecutive of at least 30,000 at home. ... RHP Gerrit Cole is the first Pirates pitcher to win each of his first four career starts in more than a century. He makes his fifth major league start in the series finale Thursday. LHP Cole Hamels (2-11, 4.58), who starts for the Phillies, has one win since April.
Rockies prospect Colton Welker is a Parkland, Florida, native and donned his alma mater's "SD" cap in a spring training game Friday, as MLB honored victims of the Feb. 14 shooting.
Francisco Liriano has landed with the Tigers on a one-year, $4 million deal, giving Detroit added pitching depth.
Coley Harvey joins SportsCenter to talk about the fan reaction to Giancarlo Stanton's debut with the Yankees in spring training.
After being "late enough to be a problem," Mets prospect Dominic Smith was scratched from the lineup of the team's spring training opener Friday.
Despite his "anticipation," Giancarlo Stanton quieted nerves for his Yankees spring training debut, going 0-for-1 with a walk in four innings.
Giancarlo Stanton talks about the new and exciting feelings to wear pinstripes for the first time while seeing live pitching in his Yankees spring training debut.