RALEIGH, N.C. — Winning by three points can be every bit as sweet and satisfying as winning by 39 or 40. Just ask the Maryland Terrapins.

Trailing by 11 points with less than eight minutes remaining, 14th-ranked Maryland clawed its way back into the game. Guard Drew Nicholas made a game-winning three-pointer from the right wing with 1.5 seconds left, lifting the Terrapins to a stunning 68-65 victory over North Carolina State.

The win moved Maryland (19-7, 11-4 ACC) within one-half game of No. 12 Wake Forest for the conference lead and was the 500th of Coach Gary Williams’s career. It was the Terrapins’ third consecutive victory, but the previous two games were 96-56 and 91-52 thumpings of North Carolina and Clemson, respectively.

“In a way, winning like this, it feels better [than those blowouts] because you get a big adrenaline rush,” said Maryland point guard Steve Blake, who had an off night offensively but made a key shot down the stretch to pull the Terrapins even at 63. “Everyone is going crazy, especially because it is on their home court.”

Said Nicholas, who had 17 points: “I really think this win shows how tough we are as a basketball team.”

Nicholas’s shot, which he said was his first game-winner since he was 13 or 14 years old, punctuated a splendid comeback as Maryland trailed for most of the physical game but outscored the Wolfpack 21-7 over the final 8 minutes 51 seconds.

During one timeout, as North Carolina State (15-10, 8-6) threatened to pull away, forward Calvin McCall spent nearly all of the break emphatically lecturing center Ryan Randle to play better. During another timeout, Williams told his players they were going to play harder and scramble more often, giving the Wolfpack more scoring chances but perhaps also speeding up the game and changing the momentum.

“I told them we were either going to lose by 30 or win this thing,” said Williams, whose team has won 18 of the past 21 games in the series, including 9 of 10 in Raleigh. “I don’t like six-point losses.”

And so, with John Gilchrist and Jamar Smith providing a spark off the bench, Maryland used its press to rally from a 58-47 deficit. Nicholas made a long jumper from the right wing, then was fouled on a three-point attempt and made three free throws and it was 58-52 with 6:30 left.

Later, a basket by Tahj Holden (career-high 20 points, nine rebounds) and a fast-break layup by Smith made it 60-57. Then McCall made a steal leading to a short bank shot by Holden and the Terrapins were within 60-59.

North Carolina State, desperately needing a victory to boost its chances of making the NCAA tournament, got a three-pointer by Clifford Crawford to temporarily stop Maryland’s run. But even after Blake stepped on the baseline for a turnover, the Terrapins were undeterred.

Marcus Melvin missed the front end of a one-and-one, then Holden made a textbook jump hook. Blake grabbed an offensive rebound and made a pull-up jumper from the right side for his only points of the game, tying the score at 63 with 2:12 left.

Julius Hodge, one of three North Carolina State players who had the flu, missed a three-point try. At the other end, Gilchrist made a putback, giving Maryland its first lead since midway through the first half, 65-63 with 1:22 left.

The Wolfpack turned it over, but after a timeout Blake missed a contested three-point shot with about 25 seconds left. Melvin then made a tough jumper from 18 feet straight out, tying it at 65 and North Carolina State Coach Herb Sendek called a timeout to set his team’s defense with 14 seconds left.

Maryland worked the clock down, then Blake passed to Nicholas on the right wing, in front of his team’s bench.

“My first thought was to drive the basketball but [defender Scooter] Sherrill kind of stepped in front of me,” Nicholas said. “I didn’t push him back, but he just kind of jumped back a little bit. That gave me enough space to let it fly.”

After the shot went through the basket, Nicholas ran the length of the court with his arms in the air in jubilation, pausing only briefly as Crawford missed a 55-foot heave. Making the game-winning shot gave Nicholas the last word on an emotional night that saw three players called for technical fouls and another called for an intentional foul.

“Let’s not sugarcoat things,” Nicholas said. “We don’t like each other. And you can see it when we step out on the basketball court. A lot of times, with other teams in the ACC, we’re more civil. When we step out on the court with them, it’s all business.”

Nicholas gave high-fives to a few dozen Maryland fans as he left the court and, a few seconds later, Williams shook hands with several friends who made the trip to see the coach reach the milestone.Williams, however, played down his personal achievement.

“It meant more to me for where we are in the league,” Williams said. “I’m not being modest or anything, I’m glad I got 500. But to win that game down here [like that], are you kidding me?”