TRENTON, N.J — After losing a doubleheader Saturday against the Trenton Thunder, the last thing the Portland Sea Dogs needed Sunday was a short outing from a starting pitcher.

So when Chris Hernandez gave up three runs in the first inning, including Melky Mesa’s two-run homer, it looked like it might be another long day for the Sea Dogs.

But Hernandez blanked Trenton for the next five innings, and the Sea Dogs battled back not once, but twice, to pull out a 6-5 win on Ryan Dent’s two-run homer in the eighth inning.

“I knew I’d hit it pretty good,’’ said Dent, who followed up Derrik Gibson’s leadoff triple with his second home run of the year. “I figured it was either a double or homer, and it just got over the wall.

“They’ve had our number.  So it’s good to get this win and hopefully grab a split in the series tomorrow. We played some good baseball today. Our pitchers did a good job and we got some big hits.

“Hopefully we can keep it up.’’

Portland overcame its early 3-0 deficit to take a 4-3 lead, then handed it right back when third baseman’s Marquez Smith’s led to a pair of Trenton runs in the bottom of the seventh.

But the Sea Dogs rallied again.

“That’s characteristic of  us,’’ said Sea Dogs Manager Kevin Boles. “Our offense has been down throughout the year and battled back. The way these guys go after their at-bats, they’ve done a good job.

“But Chris (Hernandez) was really efficient the whole game after he started out slow.  He established his fastball and attacked the zone. We were a bit short (in the bullpen) today after the doubleheader, and he gave us some good innings.’’

Hernandez left after the first three batters of the seventh reached base. Caleb Clay (2-2) pitched two scoreless innings, and Brock Huntzinger closed it out in the ninth.

After a leadoff single and a sacrifice, Huntzinger had to sweat out Yadil Mujica’s drive to the warning track in right for the second out before getting Abraham Almonte to fly to center.

“(Mujica) put a pretty good swing on it, but I knew it wasn’t the end of the game,’’ said Huntzinger, who began the season in the rotation.

“It’s definitely a cool experience to be on the field when the last out is made. I like being the guy. But whatever they want from me is fine.’’

The Sea Dogs began their comeback when Matt Spring hit a two-run double in the second inning. Bryce Brentz scored on a wild pitch to tie the game in the fourth, and Gibson singled home Dan Butler in the sixth.

The Sea Dogs are now 3-10 this season against the Thunder. They play nine more times in the next two weeks, including a five-game home series starting Saturday.

“They’re a very good club,’’ said Boles. “They’re tough, aggressive, have good starting pitching and good hitters.’’

NOTES: First baseman Reynaldo Rodriguez left the second game of Saturday’s doubleheader when a pitch hit him on the hand, but Boles expects him back in the lineup soon. … The newest Sea Dog is reliever Jason Urquidez, 29, who was pitching for an independent league team in Lancaster, Pa. Urquidez was drafted by the Diamondbacks in 2005 and pitched parts of four seasons in Triple-A.