The Portland Sea Dogs and Richmond Flying Squirrels both lost leads Wednesday night, sending the game into extra innings before 5,797 at Hadlock Field.

Brandon Bednar won it for Richmond, singling home two runs in the 11th for a 7-5 victory.

Jeremy Barfield hit a two-run double and Jordan Procyshen added a solo home run for Portland (50-57). Reliever Jacob Dahlstrand (5-2) took the loss.

Kevin McAvoy came off the disabled list (back) and made his first start for the Sea Dogs since July 13. He gave up five runs on six hits and two walks over 31/3 innings.

Josh Tobias of the Portland Sea Dogs pivots to turn a double play Wednesday night as Myles Shroder of the Richmond Flying Squirrels is forced at second. Staff photo by Shawn Patrick Ouellette

Trevor Kelley made his eighth relief appearance for the Sea Dogs and it was easily his best, pitching a near-perfect 31/3 innings. He retired 10 of 12 batters, allowing a walk and hitting a batter.

Ty Buttery relieved Kelley and threw three innings of two-hit ball, working his change-up well off his 98 mph fastball.

The Sea Dogs took a 2-0 lead in the first when Barfield swatted his two-run double to right-center. Barfield, who went 2 for 5, has a 12-game hitting streak (19 for 48 with 19 RBI).

Portland went up 4-2 in the second with RBI by Danny Mars (double) and Cole Sturgeon (groundout).

Richmond’s C.J. Hinojosa turns a double play as Portland’s Josh Ockimey slides into second base. Staff photo by Shawn Patrick Ouellette

Richmond (47-61) scored three in the fourth for a 5-4 lead. But Procyshen tied it in the bottom of the inning with his blast. Procyshen’s third homer of the season flew off his bat (106 mph) and sailed over the right-field wall, an estimated 414 feet.

In the bottom of the 10th, Josh Ockimey, called up to Portland on Tuesday from Class A, got his first Double-A hit with a double to left field. After an out, Josh Tobias was intentionally walked. Both runners were stranded as reliever Cody Hall (3-2) struck out Procyshen and Mars.

Dahlstrand relieved in the 11th. He gave up a single but was ahead 0-2 on the next batter. Dahlstrand then threw eight straight balls to walk two and load the bases with no outs.

Bednar swung at the first pitch and lined a single to left, scoring two.

The Flying Squirrels brought in closer Tyler Cyr to face the top of Portland’s order in the 11th. Sturgeon led off with a single up the middle.

But Cyr recovered, striking out Chad De la Guerra, inducing a groundout by Michael Chavis and a flyout by Barfield.

Sea Dogs pitcher Kevin McAvoy delivers a pitch against the Richmond Flying Squirels. Staff photo by Shawn Patrick Ouellette

It was Cyr’s 14th save, tying him for second in the Eastern League.

NOTES: Red Sox Manager John Farrell told media in Boston that reliever Carson Smith will make a rehab appearance with the Sea Dogs in Saturday when Portland plays Bowie at 7 p.m. Smith, obtained in a trade before the 2016 season, was with the Sea Dogs when he last pitched in games (April 29-30, 2016). That rehab assignment did not go well and Smith underwent Tommy John surgery the next month.

After Wednesday’s game, the Sea Dogs have averaged 5,323 fans a game, fourth-best in the Eastern League. … Thursday’s game will feature a noon start.

Kevin Thomas can be contacted at 791-6411 or at:

[email protected]

Twitter: KevinThomasPPH