Updated

Freshman Chelsea Gray hit a driving layup with 12 seconds left to help No. 3 Duke rally from a 20-point deficit to beat rival North Carolina State 65-64 on Sunday.

Jasmine Thomas scored 14 points to lead the Blue Devils (19-0, 5-0 Atlantic Coast Conference), who had to fight to the final horn to remain the nation's last unbeaten team. Duke trailed by 18 at halftime and 42-22 a minute into the second half before turning up its defensive fullcourt pressure to finally get back in the game.

Gray's driving layup against Amber White gave the Blue Devils the lead for good, though the Wolfpack had two good looks at the end to steal back the win. First, Marissa Kastanek missed a straightaway 3-pointer, then Bonae Holston hit the front of the rim on a midrange stickback attempt.

Krystal Thomas came down with the rebound just before the horn sounded to give the Blue Devils a thrilling victory.

It is believed to be the first time the Blue Devils have rallied from a 20-point deficit for a victory since winning 68-67 at Connecticut on a buzzer-beating 3-pointer from Jessica Foley in January 2004.

Thomas and Gray each finished with 13 points for Duke, which overcame a horrendous start and a frustrating day at the free-throw line (12 for 23) by shooting 56 percent after the break. The Blue Devils also forced the Wolfpack (9-10, 1-4) into 14 second-half turnovers, which helped Duke inch its way closer as the final 8½ minutes wore on.

Kastanek and Kody Burke each had 14 points to lead N.C. State, which shot 52 percent in the first half but just 32 percent (8 for 25) after halftime to watch what would have been a huge win for second-year coach Kellie Harper slip painfully away.

The Wolfpack led 59-44 on Holston's turnaround jumper against Kathleen Scheer with about 8½ minutes left, but that ended up being N.C. State's final field goal.

Meanwhile, Duke — after watching N.C. State turn away several comeback attempts with timely baskets — finally built some momentum with a 15-2 run, then went ahead for the first time in the second half when Thomas scored over Holston for a 63-62 lead with about 2 minutes left.

Kastanek answered with two free throws with 29.4 seconds left to put N.C. State back in front, but Gray answered seconds later with the biggest basket of the game.

It was quite a reversal from the way the Blue Devils started the game. Duke missed 16 of 18 shots to open the game, which included a 9-minute drought without a field goal, while the Wolfpack built some confidence and momentum as it pushed ahead. N.C. State closed the first half by scoring six straight points for a 40-22 lead at the break, then took its largest lead on Burke's jumper in the lane with 19:09 left.