BINGHAMTON, N.Y. — The Portland Sea Dogs committed infield errors in each of the final two innings Wednesday night, opening the door for the Binghamton Mets to emerge with an 8-5 victory in Game 1 of their Eastern League Eastern Division playoff series.

T.J. Rivera won it, hitting a three-run homer with two outs in the ninth inning, completing Binghamton’s comeback from a four-run deficit in the opener of the best-of-five series.

“I think we’ll be fine,” said Sea Dogs designated hitter David Chester, who hit a three-run homer in the sixth to give Portland a 5-1 lead. “We have a good group of guys here.

” … It happens. It’s baseball. Yeah, it’s the playoffs but we’ve been in situations before. I think we’ll come right back at it (Thursday).”

The Sea Dogs have one more game in Binghamton before getting to use the home-field advantage they earned with the Eastern Division regular-season title. Games 3 through 5, if necessary, will be played Friday through Sunday at Hadlock Field.

Binghamton ended the regular season on a six-game losing streak and was in trouble in the playoff opener before scoring the game’s final seven runs, including the last five unearned.

“A lot of work went into making the playoffs,” said winning pitcher Cody Satterwhite, who pitched a scoreless inning with the help of a strikeout to get out of a first-and-third situation. “Sure you want to win the division but when you get to the playoffs, anybody can win the series.

“You just have to forget about those last few games. … Winning that way takes a lot of momentum into (Thursday).”

The Sea Dogs tossed away momentum when second baseman Sean Coyle flipped over the ball over shortstop Ryan Dent while trying to get an eighth-inning forceout. Third baseman Mike Miller then misplayed a routine grounder in the ninth.

“We misplayed a couple balls that led to five unearned runs,” Sea Dogs Manager Billy McMillon said. “At this point in the season, those can prove big enough to lose a ball game.

“We appeared to have some command of the game until those errors.”

Rivera, who finished 4 for 5 with three runs and five RBI, doubled in Wilfredo Tovar to cut the Sea Dogs’ lead to 5-3 with one out in the eighth.

Brian Burgamy then walked. When Jayce Boyd hit a grounder to Coyle, he threw high, allowing Rivera to score and Burgamy to take third. Burgamy scored on Darrell Ceciliani’s sacrifice fly.

Losing pitcher Noe Ramirez would have retired the first five batters he faced if not for the errors.

Miller’s miscue with one out in the ninth started the winning rally. Tovar followed with a single. Ramirez struck out Brandon Nimmo but Rivera ended the game on the next pitch.

Binghamton starter Tyler Pill remained unbeaten in his last 17 starts and 18 appearances because of the rally.

Pill retired the first 11 Sea Dogs until Coyle hit a fourth-inning homer for a 1-1 tie.

Portland scored four times in the sixth, using power and speed to knock out Pill.

Cuban outfielder Rusney Castillo, making his debut with the team, reached on an infield single, stole a base and scored on a Keury De La Cruz single. Chester later hit his three-run homer.

Castillo left in the sixth, as planned, and finished 1 for 3.

“It’s too early. It’s too small a sample,” McMillon said when asked to assess Castillo’s debut. “You can see some tools there in batting practice and you could see he stole third base easily.”

Brian Johnson, who posted the EL’s lowest ERA since 1985, was in position to win for the Sea Dogs. He went seven innings, giving up two runs on six hits and a walk, striking out eight.

NOTES: The Sea Dogs were well-represented when the Baseball America publication named its minor league all-star team.

Catcher Blake Swihart, second baseman Mookie Betts and starting pitcher Henry Owens were first-team selections. Johnson, who pitched for Class A Salem before the Sea Dogs, was a second-team pick.