MIAMI — Cole Hamels kept delivering for the Phillies this season, all the way through his final start.

Hamels struck out eight while allowing five hits and one run over seven innings, Carlos Ruiz had a three-hit game and the Philadelphia Phillies beat the Miami Marlins 4-1 Sunday.

Hamels (17-6) walked only one in his final start of the year for the Phillies (80-79), who need one win in the final three-game series at Washington starting Monday to finish at least .500 for the 10th straight season.

Hamels’ final numbers this year are better than what he did over his previous five seasons, ones where the Phillies found their way to the postseason every time. From 2007-11, he averaged 13 wins, 189 strikeouts, a 3.88 strikeout-to-walk ratio and a 3.31 ERA.

This season, he exceeded the average win number over that span by four, the average strikeout number by 27 (a career-best 216), his strikeout-walk ratio was 4.15 and his ERA ends up at 3.05.

No wonder the Phillies gave him a $144 million, six-year deal in July.

“I’m happy with the direction that I guess I’m going,” Hamels said. “It’s kind of a selfish way that you think about it, but I’m happy that I’m going to be on this team and I like all the possibilities that we have.”

Jonathan Papelbon worked his way around a pair of singles in the ninth to get his 38th save in 42 tries.

Jose Reyes had a pair of hits and Carlos Lee drove in a run for Miami, which lost for the 21st time in its last 29 games. Marlins starter Nathan Eovaldi (4-13) gave up three runs — all in the first — and struck out seven in six innings.

“We gave him another inning to survive his problem and he did it,” Marlins manager Ozzie Guillen said. “I mean, you take that inning away from him and to me he pitched good enough.”

By the time Hamels took the mound, the Phillies had staked him to a 3-0 lead. And with the way Hamels was throwing — 6-0 as the Phillies won nine of his last 10 starts — that cushion looked enormous.

Hamels retired his first 10 batters and threw 31 of his first 39 pitches for strikes. Maybe his early success shouldn’t have been that surprising, considering Hamels entered with a better batting average (.227) than four players in the Marlins’ starting lineup (Gorkys Hernandez, .177; Bryan Petersen, .193; John Buck, .197; and Eovaldi, .100).

About the only throws Hamels struggled with were ones to first and second.

Hamels tried to make a pickoff throw to second base in the fourth, sending it past shortstop Jimmy Rollins and allowing Reyes to jog to third. Reyes scored on Lee’s single as the Miami closed to 3-1. But the margin got no smaller, as Petersen and Giancarlo Stanton were thrown out at home in the inning.

Another errant throw by Hamels put Reyes on the move again in the sixth, but the Phillies escaped unscathed.

Hamels fielded Reyes’ bunt and threw past first base — replays suggested Reyes would have beaten it anyway. Reyes went to second on the error, then stole third, but Hamels stranded him after getting Stanton to pop up in the infield and striking out Lee.

Hamels finished the year with 215 1-3 innings. According to STATS LLC, the only players entering Sunday with at least 215 innings and 215 strikeouts this season were Detroit’s Justin Verlander, the New York Mets’ R.A. Dickey, Seattle’s Felix Hernandez and the Los Angeles Dodgers’ Clayton Kershaw.

“I think before his career is over he’s going to win 20,” Manuel said.

Chase Utley hit a sacrifice fly in the first for Philadelphia, followed by a run-scoring double by Ruiz and an RBI single from Nate Schierholtz. Juan Pierre helped set up the inning with a sneaky slide into second on a play where the throw from the outfield clearly beat him to the base, but he found a way to avoid the tag.

Later in the first, the Phillies had Ruiz caught off second when Reyes caught a line drive hit by Domonic Brown. But Reyes’ flip to second baseman Donovan Solano was errant, Ruiz got back safely, and scored one batter later on Schierholtz’s single.

From there, Eovaldi settled down.

“It’s huge, and I can take that into the offseason,” Eovaldi said. “It’s good to be able to make it into the sixth, seventh inning and save the bullpen. It’s something I can build on.”

NOTES: Philadelphia won the season series 10-8. ... Phillies RHP Tyson Brummett had his contract selected and will join the team in Washington on Monday. Philadelphia transferred C Brian Schneider to the 60-day DL. ... Philadelphia sends RHP Kyle Kendrick to the mound in Washington on Monday to face Nationals’ LHP John Lannan. Miami stays home to face the Mets, with RHP Josh Johnson going for the Marlins against New York RHP Jeurys Familia.