BALTIMORE — One out from completing the seventh inning Thursday night, Nick Pivetta trudged back to the Phillies dugout after giving up a 400-foot, two-run home run on his 102nd pitch of the game.

OK, so it wasn't the way Pivetta wanted to punctuate his final start before the all-star break.

Still, this represented progress. Given the gift of facing the dreadful Baltimore Orioles for a second time this season — thanks to a torrential rainstorm May 15 that postponed the game by nearly two months — Pivetta didn't allow a hit until the sixth inning. He pitched into the seventh inning for only the second time in nine starts. And he got a win in a start for the first time since May 21, a 5-4 decision that nudged the Phillies (52-40) a half-game ahead of the Atlanta Braves and into sole possession of first place in the National League East.

"We needed this from Nick," manager Gabe Kapler said. "We needed him to go deep into the game. He did. We needed him to establish his fastball again. He did. And I think he needed it for him. He needed it for his confidence levels."

The Phillies pounded 14 hits, including three apiece by Jorge Alfaro, Scott Kingery, and Cesar Hernandez. Alfaro lined a two-run double in the fourth inning to open a 4-0 lead and crushed a solo homer to straightaway center field in the sixth.

And the bullpen delivered once again, too. Four relievers — Tommy Hunter, Edubray Ramos, Adam Morgan, and Seranthony Dominguez — combined to record seven outs. Less than three weeks until the trade deadline, the Phillies bullpen has quietly posted a 1.89 ERA in July, the lowest mark in the majors.

But nothing that transpired before an announced Camden Yards crowd of 20,100 fans — enough of whom were rooting for the Phillies that a loud "E-A-G-L-E-S, Eagles!" chant broke out midway through the game — was more important than Pivetta's performance.

The 25-year-old righthander didn't make it out of the third inning in his previous start. In the start before that, he got knocked out in the second inning. His ERA since June 1: 7.34.

But one night after Vince Velasquez affirmed his spot in the starting rotation with six sparkling innings against the New York Mets, Pivetta did the same against the Orioles, who have the worst record in baseball (26-68) but nevertheless still possess Manny Machado, Adam Jones, Mark Trumbo, and a few other dangerous hitters.

"It was nice to get back on track," Pivetta said. "It definitely gave me a little more confidence booster."

Pivetta established his fastball early and had success with his curveball. But the game could have  unraveled for him in the second inning, when errors by first baseman Carlos Santana and shortstop Kingery put runners on second and third with one out. Instead, Pivetta struck out Chance Sisco and got Trey Mancini to get out of the jam without allowing a run.

"That right there in the past has turned into maybe a crooked number," pitching coach Rick Kranitz said. "That's when youth sometimes gets in the way. Maybe the game will speed up at times like it does for everyone. I just think you look at his straight numbers, they're pretty impressive."

Pivetta will close the first half with a 4.58 ERA and 1.318 walks/hits per inning pitched in 96 1/3 innings. Velasquez takes a 4.39 ERA and 1.240 WHIP in 94 1/3 innings into the break. Neither will win any awards with those numbers (league averages are a 4.10 ERA and 1.293 WHIP), but they have pitched well enough to mute calls for prospect Enyel De Los Santos to join the rotation, even after he won his major-league debut in a spot start earlier this week.

"Nothing's guaranteed. I think they know that," Kranitz said. "They've been here long enough now where they've pitched enough major-league games to realize, hey, I just need to do my job, I need to worry about myself and do what I can do. Each guy has kind of stepped up."

Pivetta, in particular, really needed it.