The Maryland men’s soccer team sensed the floodgates were opening offensively after midfielder Amar Sejdic scored the first goal of the season Monday against West Virginia.

Yet for the first 83 minutes minutes of the team’s Big Ten opener at Northwestern Friday night, a frustrating 1-0 loss seemed imminent despite generating a season-high on shots.

But then, forward William James Herve took over. The freshman scored two goals in an 11-minute span, forcing overtime and then ending it to give the Terps a 2-1 sudden-death victory.

Just five minutes into the extra period, Herve took a shot from outside the box that bounced twice before skipping between Northwestern goalkeeper Miha Miskovic’s legs for the game-winner.

“The shot I took was poor,” Herve said. “The goalkeeper made a mistake and it went in the back of the net. But I’m happy. It was a great feeling.”

The Terps (2-2-2, 1-0 Big Ten) felt they deserved the win with a dominant 20-4 shot advantage. But in the 61st minute, Maryland found itself in desperate need of a score.

After being held without a shot in the first half, Northwestern’s third strike in the first 15 minutes after halftime put the Terps down with about 30 minutes remaining in regulation. Terps midfielder Andrew Samuels headed away a cross to the top of the box, but before the ball even hit the ground, midfielder Camden Buescher fired it into the back of the net to give Northwestern a 1-0 lead.

With just one goal in its first five games, Maryland needed to two goals to start the conference slate with the win it wanted, despite four players being unavailable.

Ben Di Rosa and Justin Gielen didn’t travel with the team because of illnesses, while Vinicius Lansade got sick on the trip to Evanston and didn’t play. Chase Gasper couldn’t play because of a back injury, a team spokesman said.

The come-from-behind win would also need to come against a stingy defense. Northwestern (4-2-1) entered the game with five clean sheets in its first six games, with all three goals they’d conceded coming in their only loss to No. 12 Fordham. Those five shutouts ranked tied for first in the country.

Maryland felt the urgency intensify with each shot that didn’t turn into a goal of its own.

“It was a bit of a frustrating game because we had so many chances,” Sejdic said. “We just couldn’t put it in the back of the net.”

The Terps pressed forward, using a new 3-5-1 formation to stimulate the offense even more after finally breaking their four-game scoreless drought on Monday.

After 20 minutes of pushing for a game-tying goal to force overtime, Maryland finally found the its moment. Defender Johannes Bergmann played a ball downfield, where forward Eric Matzelevich headed it into the box. Forward Sebastian Elney kept the play alive by redirecting the ball to Herve.

The Frenchman had just enough room to slip an equalizer past Miskovic, who remained in a motionless squat as he watched the ball trickle past him.

“They scored a wonder goal and now we had to find some resolve to equalize, which we did,” Maryland coach Sasho Cirovski said. “We showed great character and that was a well-deserved goal that we scored.”

For the third time this season, Maryland headed to overtime. On this occasion, though, the result wouldn’t be a scoreless double-overtime draw.

On Maryland’s first shot of overtime — and 11th since conceding the early second-half goal — Herve scored his second goal of the game on Miskovic’s brutal error. Elney, who missed the previous two games with an ankle injury, slipped a pass to a well-positioned Herve, who ripped his shirt off, twirled it around in circled and flung it into the sky in celebration after Maryland’s second consecutive win.

After an 0-2-2 start to the season — tied for the worst in program history — the Terps are back to .500 after the gift from Miskovic.

“We got a little fortunate on the winner, something we haven’t had much of recently,” Cirovski said. “We certainly deserved this victory and I wish we could’ve done it in regulation, but this is another good character-building win for this group.”