The Maryland baseball team had endured a pattern of errors in their losses to start the season, and a late mistake Friday appeared likely to doom the Terps’ chances against Notre Dame. Right fielder Marty Costes committed an error on a deep ball in the seventh inning to help the Fighting Irish take a one-run lead into the ninth.

But this time, the Terps overcame the defensive miscue to top Notre Dame, 4-3, at the USA Baseball-Irish Classic is Cary, North Carolina.

In the final frame, a Notre Dame error on a popup by first base — similar to Maryland catcher Nick Cieri’s mistake on a comparable play in the first — allowed center fielder Zach Jancarski to reach first base with one out. Then, designated hitter Brandon Gum’s RBI single tied the game, and catcher Dan Maynard’s sacrifice fly gave the Terps a lead they wouldn’t relinquish.

Right-hander Ryan Selmer kept the Fighting Irish off the board in their final at-bats, similar to the prowess right-hander Brian Shaffer (six innings with one earned run) displayed for the majority of his start.

“This was a game both teams kind of struggled in early,” Gum said. “It’s a game we wanted to show we’re not playing as bad as our record shows. We played some really good teams…We needed a good win.”

Shaffer held Notre Dame scoreless through his first six innings but couldn’t record an out in the seventh. He allowed a pair of singles to open the frame before Costes failed to field the fly ball close to the warning track. He held his hands in the air and thought he caught the ball, and coach John Szefc disputed the call. But after an RBI groundout and safety squeeze, Notre Dame earned its first lead.

In perhaps the most commanding of his three starts this season, Shaffer tossed six innings and allowed three runs — one earned — while issuing one walk. He tied a career high with eight strikeouts and, at one point, retired nine consecutive Fighting Irish hitters.

Maryland, though, couldn’t hold the 2-0 lead it touted after Cieri’s first-inning RBI double and Gum’s RBI walk with the bases loaded in the seventh.

“It was kind of deflating,” Gum said of the mood in the dugout after Notre Dame’s three runs in the seventh. “A big thing that we talked about it staying up. The dugout did a great job of staying up and next inning we kept working for it. It ended up turning out alright.”

Still, the Terps rallied against Notre Dame left-hander Sean Guenther and right-hander Matt Vierling to earn their second win of the season.

After defensive woes proved costly in Maryland’s first two weekend series, Gum and Maynard provided insurance to start this tournament’s slate.

“Great team effort there,” said right-hander Ryan Hill who earned his first career win with Maryland. “It feels good to get the win for sure.”