PITTSBURGH (AP) — Andrew Knapp had too much fun to be tired after playing in what matched the longest nine-inning game in NL history.

Knapp and Odubel Herrera hit three-run homers, rookie Scott Kingery had a career-high four hits, and the Philadelphia Phillies beat the Pittsburgh Pirates 17-5 on Friday night for their fifth straight victory.

Herrera's shot into the right-field stands in the third inning off Trevor Williams (6-7) pushed the Phillies' lead to 5-1. Knapp's blast to left capped a seven-run seventh, making it 14-4 and helping Philadelphia improve to 5-0 against the Pirates this season.

The game lasted 4 hours, 30 minutes, tying the NL record for a nine-inning game set on June 24, 2016, by the Arizona Diamondbacks and Colorado Rockies.

"Was it that long?" Knapp said. "It didn't seem like it."

It felt like an eternity for Pittsburgh, which has given up 48 runs, 59 hits and 12 home runs during its four-game losing streak.

"It's peaks and valleys. Right now, collectively, we're in a valley," Williams said.

Herrera finished with four RBIs and Carlos Santana drove in three runs. Cesar Hernandez and Rhys Hoskins had three of the Phillies' 18 hits and Maikel Franco hit a two-run double in the second.

Kingery reached base five times.

Philadelphia (48-37) moved into a first-place tie with Atlanta in the NL East and is 11 games over .500 for the first time since the end of the 2011 season. The Phillies lost 96 games last year.

"We played Phillies-type of offense," first-year manager Gabe Kapler said. "We continue to see a lot of pitches, work a lot of counts, grind down the opposing pitchers. I really believe it's a great way to win baseball games and our guys are starting to understand it and going along with it more and more."

Edubray Ramos (3-0) retired both batters he faced in the fifth inning after being activated from the disabled list before the game.

Both starting pitchers were chased in the third inning. Nick Pivetta was charged with three runs — one earned — and Williams was tagged for five runs.

"I kind of set the tone for the record," Pivetta said with a smile, "but our guys did a good job of battling and overcoming it."

Pivetta has made eight starts in a row without a victory, though he got the win in relief Sunday against Washington. Williams has lost his last three starts, allowing 12 runs in 13 innings.

"I'm tired of getting my (behind) kicked," Williams said.

The Phillies sent 11 batters to the plate in the seventh to take a 10-run lead. Hoskins and Herrera hit consecutive RBI singles and Santana doubled home two runs before Knapp connected against Josh Smoker.

Jesmuel Valentin belted a two-run double and scored on a double by Hoskins in the ninth.

Pittsburgh's Colin Moran opened the scoring with an RBI single in the first.

ROSTER MOVES

Phillies: Ramos had been out since June 25 with a right shoulder impingement. Fellow RHP Jake Thompson was optioned to Triple-A Lehigh Valley.

Pirates: OF Jordan Luplow was recalled from Triple-A Indianapolis and RHP Clay Holmes was optioned to Class A Bradenton. Holmes was sent to the Florida State League to stay on a normal schedule because the Triple-A All-Star break is next week.

MARTE MILESTONE

Marte stole his 200th career base in the fourth inning and added two more steals in the sixth. He is the eighth Pirates player since 1900 to reach that milestone.

TRAINER'S ROOM

Phillies: RHP Vince Velasquez (bruised right forearm) will throw a bullpen Saturday and likely start Wednesday night against the Mets at New York. . RHP Jerad Eichkoff (right lat strain) felt tingling in his fingers during a live batting practice session Friday at the spring training complex in Clearwater, Florida. ... INFs J.P. Crawford (broken left hand) and Pedro Florimon (broken right foot) will be examined by specialists next week.

Pirates: RHP Joe Musgrove (infected right index finger) is scheduled to throw a bullpen Saturday. . C Francisco Cervelli (concussion) is 1 for 5 with three walks through the first two games of his rehab assignment at Double-A Altoona. ... INF/OF Sean Rodriguez (strained right quadriceps) is 5 for 20 with a double in five games with Indianapolis.

UP NEXT

Phillies: RHP Jake Arrieta (5-6, 3.54 ERA) is 0-4 with a 6.16 ERA in his last six starts.

Pirates: RHP Jameson Taillon (5-6, 4.05) is 3-6 with a 4.93 ERA in his last 14 starts after going 3-0 with a 0.89 ERA in his first three.