The line of students snaked beyond the parking lot, past the brick buildings behind Ludwig Field. They filled the Maryland soccer stadium to capacity well before kickoff, and when the entry gates closed, those left standing outside climbed over the perimeter fences anyway. A record-breaking crowd of 8,397 was rewarded Friday night as the Maryland men’s soccer team, in its first ACC game of its last ACC season, rallied for a 3-1 win over Duke.

“One of the great magical nights in Maryland soccer history,” Coach Sasho Cirovski said.

A season-opening tie at Stanford and a one-goal overtime defeat at California last week sent Maryland tumbling from second to 13th in the latest NSCAA top 25 poll. But three unanswered goals helped the Terps dodge their first three-game winless start since 1992, the year before Cirovski arrived in College Park and began transforming the program into a national power.

Midfielder Helge Leikvang headed through the winner off a corner kick from Tsubasa Endoh and fled to the corner flag to celebrate. Endoh had rejoiced in similar fashion earlier in the second half, when his left-footer crossed up Duke keeper Alex Long and tied the game at 1, erasing another first-half deficit.

“We know our way to play,” Leikvang said. “We know we’re going to grind out teams. They might get a lucky goal, but we’re going to possess the ball. We’re going to keep coming at you until we get one. We’ve been in that position before. We’re used to it by now.”

The Blue Devils broke through in the 25th minute on midfielder Sean Davis’s free kick that curved past diving goalie Zack Steffen. But the four true freshmen, including Steffen, who start along Maryland’s back line helped staunch the bleeding. Steffen halted a one-timed bullet from Seo-in Kim at point-blank range early in the second half, and Endoh struck his equalizer on the ensuing counter-possession.

“I thought the discipline was outstanding today,” Cirovski said. “We didn’t give many fouls away. We didn’t make many mistakes. Staying tuned into the whole process is important. When you put a Maryland soccer shirt on, you’re going to get everyone’s best game. And we did out west. And we came back.”

Just more than two minutes later, first-team all-American and MAC Hermann Trophy winner Patrick Mullins one-timed Endoh’s low cross into the net. The Terps had peppered Long with nine shots by halftime and 19 overall, including a header by Alex Crognale that caromed off the right post and a right-footed rip by Mullins that Long bent backward to save. Breaking through seemed inevitable, especially for a team that returned seven starters from last season’s College Cup semifinalists.

“Tonight, you couldn’t fault the guys,” Cirovski said. “They were great. The chances were there. We hit the goal posts. A couple went woefully wide. Those goals will go in. If we keep doing the right things, the ball will end in the back of the net.”

GEORGETOWN 3, WEST VIRGINIA 0: Forward Brandon Allen scored twice and added an assist as the No. 11 Hoyas blanked the Mountaineers at Shaw Field.

VIRGINIA WOMEN 6, RUTGERS 0: A battle of undefeated teams turned out one-sided as the No. 4 Cavaliers routed the Scarlet Knights in the Virginia Nike Soccer Classic at Klockner Stadium.