The memory had already faded for Alex Len, lost among a sea of Comcast Center court-stormers and thumping jubilation. With 0.9 of a second left, he soared through the lane, a 7-foot-1 savior answering Pe’Shon Howard’s air-balled prayer. Minutes later, he was the unwilling provider of a piggy-back ride, carrying multiple Maryland fans until the weight proved too much, and Len toppled to the floor.

The Terrapins had stumbled in game-winning situations before this season. Howard launched an ill-advised three-pointer vs. Kentucky in the season opener. Seth Allen had his three-pointer swatted against Florida State. So as the clock ticked down and his players screened down rather than up, when Howard’s baseline drive was met by three North Carolina State defenders, Coach Mark Turgeon thought to himself, “Oh no.”

How quickly fear turned to madness in College Park Wednesday night. Len’s tip-in gave Maryland (14-3, 2-2 ACC) a wild 51-50 win over the No. 14 Wolfpack (14-3, 3-1 ACC), at once the emotion of a snapped 17-game losing streak against ranked opponents and consecutive ACC losses spilling onto the floor from the sellout crowd.

“You have to be good and you have to be lucky,” Turgeon said. “We were pretty lucky there at the end to get the win. . . . It’s just one game. We’re going to celebrate. I was happy for these guys, the students stormed the court and all that stuff. But, we just talked about it, we haven’t won a big game since Greivis [Vasquez] was here. I didn’t come here to be mediocre, and I don’t think the players came here to be mediocre.”

Mediocrity only scratches the surface for Maryland’s offense, which slogged through three miserable halves bridging losses to Florida State and Miami. But this seemed like a rejuvenated group. Everything from their state flag “Pride” uniforms to Turgeon’s seventh starting lineup in 17 games pointed to a turned corner.

Down 50-49 after Lorenzo Brown stuck a jumper with 1 minute 43 seconds remaining, the Terrapins survived one offensive rebound by Richard Howell and two missed jumpers from Scott Wood. But James Padgett snatched the second miss, drawing an over-the-back foul from Howell. After a timeout, Howard caught the inbounds pass and drove up the floor.

“It’s a great feeling,” said Allen, who finished with nine points. “All week Coach talked about making a mark in history. He’s always stressed that it takes hard work. I think we worked hard and got a great win tonight.”

Maryland hadn’t beaten a ranked team since an upset of Duke on March 3, 2010, and entered Wednesday’s game insisting that the problems of late stemmed from poor execution, not a lack of confidence. Chastised for their weak nonconference schedule, weaknesses exposed at home and in Coral Gables, Fla., the Terps finally gutted out a win.

Len finished with 10 points and six rebounds, the only Maryland player in double figures. Howard, who entered without a field goal through three conference games, was just 3 for 9 from the field, but fired a no-look alley-oop to Len against North Carolina State’s zone defense that put Maryland ahead 49-48. Brown had a game-high 17 points for the Wolfpack, who just days ago were surrounded by their bouncing classmates, reveling in a win over top-ranked Duke.

But this was Maryland’s night, right from the 10-0 lead the Terps surged to in the first half, up until the moment Len spiked Wood’s last-ditch pass and the celebration began.

“I said after the Miami game, we got better in that game,” Turgeon said. “We got better, and we competed. That’s a step in the right direction. Right now, I said we’ve got to hang our hat on defense, keep guarding, keep rebounding, and hope we can outscore them by one.”

The opening period contained all the statistical atrocities of Maryland’s sluggish loss to the Hurricanes, but without the maddeningly slow pace. Halftime brought a 22-16 Terps lead, and both teams combined to shoot 26.2 percent from the field, many of the misses from the accelerated transition game. Jake Layman sprung the lead to 37-30 after halftime with a corner three-pointer off another screen-heavy in-bounds play.

The Wolfpack took its first lead with 4:35 left on a deep Wood three-pointer, capping a 15-3 second-half run coinciding with its switch to a 2-3 zone defense, which forced the Terps to settle for outside shots and rendered the post-entry pass nearly non-existent.

That is, until Len took over. The sophomore center scored Maryland’s only six points over the final four minutes, none bigger than the final play, when Howard’s floater sailed two feet wide right, and all that remained was open pasture between Len, the basket and a much-needed win.