Philadelphia (24-16) climbed eight games over .500 for the first time since the end of the 2011 season. The Orioles (13-29) have dropped two of three and have the second- worst record in the American League, ahead of only the Chicago White Sox.
Pivetta (3-2) won his second straight start, allowing one run, two hits and one walk in seven inning.
Odubel Herrera singled in the first and extended his on-base streak to 42 games for the Phillies, who have won six of seven.
Tommy Hunter allowed runners to reach second and third with one out in the eighth. Luis Garcia loaded the bases with a walk to Trey Mancini, then retired Adam Jones on a flyout and got Manny Machado to hit into a forceout.
Edubray Ramos struck out both batters he faced in the ninth, and Hector Neris retired Chris Davis on a game-ending groundout.
The opener of a series between teams that met for the 1983 title was rained out Tuesday and was rescheduled for July 12
Jones extended his hitting streak to 11 games with a first-inning homer. Pivetta then retired 12 straight batters before Davis hit a double in the fifth.
Hernandez thomered on Andrew Cashner's first pitch of the sixth inning, and Maikel Franco chased Cashner with a run-scoring single.
Richard Bleier gave up Pedro Florimon's RBI single.
Cashner (1-5) allowed three runs, five hits and three walks over 5 2/3 innings. He has not won since April 5.
Hernandez tripled in the seventh and scored on Rhys Hoskins' double off Mychal Givens.
Orioles: RHP Darren O'Day (hyperextended right elbow) threw a bullpen session without any setbacks. He could be activated Friday, according to manager Buck Showalter.
Phillies: Vince Velasquez (3-4, 5.05 ERA) is looking to earn a third straight win Thursday against the Cardinals and Luke Weaver (3-2, 4.91 ERA).
Orioles: Kevin Gausman (3-2, 3.18 ERA) starts the opener Thursday in Boston opposite David Price (3-4, 4.89 ERA). Gausman, who earned a win in his last outing against the Rays, is working on an extra day's rest for the second consecutive outing.
More AP baseball: https://apnews.com/tag/MLBbaseball