Baseball America called him one of “the best pure hitters in the Red Sox system,” but Portland Sea Dogs first baseman Nick Longhi was batting .170 on April 24.

“Just had to focus on the next game,” he said.

It’s working. Longhi is back to form, including a 2-for-4 night Wednesday at Hadlock Field.

Longhi had an RBI but the Sea Dogs fell short in a 6-5 loss to the Binghamton Rumble Ponies.

Longhi, 21, and ranked Boston’s 14th top prospect by Baseball America, has hit in 10 of his last 12 games (16 for 44, .364).

“Starting to figure things out,” he said. “It’s just getting into a groove, getting comfortable in this place.”

Sea Dogs Manager Carlos Febles moved Longhi to the cleanup spot this week.

“We told him, ‘this is where you belong,’ ” Febles said. “He’s a good hitter. Now he’s doing what he normally does, and that’s hit the ball to all fields.

“At times he was trying to do too much and it wasn’t clicking. He went back to being the hitter he is.”

Longhi’s RBI single to right field came in a four-run first inning. The Sea Dogs looked like they might break it open, but the Rumble Ponies tied it with four in the second against Sea Dogs starter Jacob Dahlstrand.

Dahlstrand walked in a runner in the fourth and was replaced by Taylor Grover, who shined with 32/3 hitless innings.

Sea Dogs outfielder Cole Sturgeon’s RBI single in the sixth tied the game, 5-5.

Portland reliever Jake Cosart (1-2) entered in the eighth and continued his struggles with control. With one out, he loaded the bases on three walks. Luis Guillorme got the game-winning RBI with a sacrifice fly to center.

Cosart, 23, ranked Boston’s 16th-best prospect by Baseball America, has walked 21 batters in 91/3 innings. In Class A last year, Cosart walked only 36 batters in 71 innings.

“He’s got good stuff. It’s just a matter of him getting in the zone,” Sea Dogs pitching coach Kevin Walker said. “His fastball’s been there. Just a matter of finding a consistent breaking ball and a consistent change-up to mix in with it.”

Portland also got RBI singles from Joseph Monge and Jordan Procyshen. Rafael Devers was 0 for 2 with two walks and two runs.

Longhi’s second hit was a double (his fifth, to go with two home runs) in the eighth inning, but he was stranded.

Binghamton lefty Kyle Reginault (2-0) got the win with 12/3 innings of relief, including a dominating seventh (nine pitches, three strikeouts). Alberto Baldonado pitched the final two innings for his sixth save.

Binghamton (18-11) moved into a first-place tie with Trenton in the Eastern League East Division.

Portland is 16-12.

NOTES: The announced paid attendance was 2,842. … Infielder Jose Rosario returned from Pawtucket and shortstop Tzu-Wei Lin went on the disabled list with a sore wrist. … The Sea Dogs left after Wednesday’s game for an eight-hour bus trip to Reading, Pennsylvania. After a four-game series with the Fightin Phils, Portland returns to Hadlock Field for a four-game series with Hartford, May 16-18. Tuesday is a doubleheader, starting at 5 p.m., and features a Jackie Bradley Jr. bobblehead giveaway to the first 1,000 fans.

Kevin Thomas can be reached at 791-6411 or:

[email protected]

Twitter: @ClearTheBases