The second overtime of a long game was winding down, and No. 25 Maryland men’s soccer coach Sasho Cirovski was growing frustrated with his attack.

“Shoot the ball,” Cirovski yelled from the sideline in the 109th minute of a match filled with missed chances.

His frustration grew as the game progressed as he watched several good opportunities go by the wayside as shots sailed off target over 108 minutes. But when Brett St. Martin redirected Matt Di Rosa’s pass into the back of the net in double overtime, his frustration turned to celebration with his team defeating No. 9 St. John’s, 1-0, on Monday night at Ludwig Field.

“Somewhere between ecstasy and relief,” Cirovski said of his feelings when the goal was scored. “You just feel so good for the players because I thought they deserved the result.”

[Read more: Maryland men’s soccer couldn’t get out of its own way in 3-1 loss to Northwestern]

The relief stemmed partly from frustration that carried over from the disappointing effort against Northwestern in Friday’s 3-1 home loss. Forward Justin Gielen said that all weekend, the team stewed on that defeat and set out to redeem itself.

But the Terps would have to reassert themselves with a different look — and without the help of three key contributors because of injuries.

Cirovski opted to switch his formation from a 4-3-3 to a 3-5-2, which allows an extra player to get further up the field and support an attack that was without three offensive-minded midfielders in Eli Crognale, William James Herve and David Kovacic.

“We went with two strikers and three in the back partly to combat some of their strengths, but partly to take advantage of the remaining players available for selection,” Cirovski said. “We’re a little thin right now.”

[Read more: Freshmen Malcolm Johnston and Justin Harris have carved out big roles for Maryland soccer]

Despite the reinforcements in the attacking third, Maryland (4-3, 0-1 Big Ten) once again entered the locker room at halftime without many positives on the attacking end of the field. Its defense, though, found its connectivity with the new three-man backline and held St. John’s (7-1) to two non-threatening shots that goalkeeper Niklas Neumann stopped.

When play resumed in the second half, both attacks began to find holes in defenses that were airtight in the first half.

“In the first half we were kind of getting used to [the new formation],” Gielen said. “In the second half, we really found our stride.”

Maryland forward Eric Matzelevich had two shots from within the box in the early stages of the second half, but both attempts went wide past goalkeeper Luka Gavran.

St. John’s also found a chance with forward Tani Oluwaseyi, winning a battle for the ball in the box before he sent a shot wide-right. Ten minutes later, a corner kick bounced outside of the 18-yard box to midfielder Brandon Knapp, who delivered a strong shot right to Neumann.

As the second half wore on, the Red Storm began to generate increasingly dangerous chances. In the 69th minute, midfielder Brandon Duarte headed a shot toward the net, forcing Neumann to make a diving save to keep the match scoreless. Just minutes later, Matt Forster couldn’t connect on a wide-open deflection attempt.

“I felt a goal was going to come somehow,” Cirovski said. “We kept pushing for it, pushing for it.”

The pursuit for the score continued, and the Terps began finding better chances, but still couldn’t convert. Two headers off set pieces sailed off the mark, and the game was pushed to two 10-minute overtime sessions.

In the second overtime, St. Martin made sure another opportunity wouldn’t pass by unheeded. After a corner kick was deflected out to Matt Di Rosa outside the box, the midfielder sent the ball into the box, where St. Martin deflected it in.

After the ball crossed the line, Maryland’s bench players flooded the field and mobbed St. Martin in the corner to celebrate the ranked victory.

“It was surreal,” St. Martin said. “It was just a great feeling. I couldn’t even describe how it is. My teammates’ support is just unreal.”