RALEIGH, N.C. (AP) Everything seemed aligned against Wake Forest: The Demon Deacons had a quarterback making his first start, an injury-depleted defense facing an offense peppered with future NFL players, and trailed by 10 points in the fourth quarter in a stadium where they almost never win,

Yet No. 22 North Carolina State couldn't seal the victory, so Wake Forest snatched it away.

Jamie Newman threw a 32-yard touchdown pass to Jack Freudenthal with 30 seconds left to give Wake Forest a 27-23 upset victory Thursday night.

''It's just about staying poised, honestly,'' Newman said. ''Staying poised and being smart, not letting the moment get too big for you.''

Making his first career start, Newman was 22 of 33 for 297 yards with three touchdown passes in the second half to help the Demon Deacons (5-5, 2-4 Atlantic Coast Conference) rally from a 10-point deficit in the fourth quarter. The 19 1/2-point underdogs earned their first road victory over a Top 25 team in a decade.

''This was going to be a game that we just have to grind, and grind, and grind, and somehow find a way to win,'' coach Dave Clawson said. ''And to our kids' credit, they did it. Every time that that thing was on the brink of getting away from us, we just did one thing to stay in it.''

Newman threw a 38-yard scoring pass to Alex Bachman before his 19-yard TD to Greg Dortch pulled Wake Forest to 23-20 with 6:07 left.

N.C. State bled nearly 4 1/2 minutes off the clock before its drive stalled at the Wake Forest 20 with 1:39 left. Newman completed 5 of 8 passes on the possession that followed, taking a hit as he connected with Freudenthal - who was wide-open after Bachman blocked two defenders - over the middle for the go-ahead score.

''We were in the huddle, and we said, `We've just got to go,''' Freudenthal said.

The Wolfpack advanced to their own 49 before Ryan Finley's final pass for the end zone was intercepted by receiver Scottie Washington - playing defensive back on the last play - to end it.

Finley finished 35 of 52 for 374 yards with a 35-yard touchdown pass to Emeka Emezie and a 2-yard touchdown run for the Wolfpack (6-3, 3-3, No. 14 CFP). The pass to Emezie put them up 23-13 one play into the fourth quarter.

After losing three of four to fall out of contention in the Atlantic Division, they'll only reach their goal of the school's first 10-win season since 2002 if they win out and win their bowl game.

THE TAKEAWAY

Wake Forest: Maybe a third straight bowl berth isn't out of the question for the Demon Deacons, who hadn't beaten a nationally ranked opponent on its home field since knocking off No. 24 Florida State in 2008 and had won in Raleigh only once in their previous 16 tries. This didn't look at all like the same Wake Forest team that was routed by No. 3 Notre Dame and No. 2 Clemson.

N.C. State: This one is going to sting the Wolfpack, who settled for three short field goals after drives stalled deep inside the red zone - twice at the 6-yard line, once at the 12. They also finished with a season-worst 47 yards rushing against the ACC's worst run defense, and on a drive that was supposed to bleed the clock, they rushed for minus-6 yards on three carries while relying heavily on Finley's throwing.

''I take responsibility any time my team doesn't play the way that it can, and I do,'' coach Dave Doeren said. ''We had a lot of opportunities, and there (are) a lot of things that happened throughout the course of the game that led to the result.''

POLL IMPLICATIONS

The Wolfpack's return to the AP Top 25 figures to be short-lived. N.C. State dropped out of the poll after losing two weeks ago at Syracuse, climbed back in following their rout of Florida State and seems likely to drop right back out.

KEY STATS

The Wolfpack averaged just 1.7 yards per carry - also a season worst - while Wake Forest had 11 tackles for losses, including four sacks. N.C. State fell to 1-3 when it averages fewer than 3.5 yards per carry.

STRATEGY SHIFT

The Demon Deacons are usually one of the fastest-playing teams in the country, averaging more than 85 plays per game. But the quarterback change and the lack of depth on defense forced Clawson to slow things down. They ran only 71 plays in this one. ''If we do what we normally do ... there's no way we hold them to 23 points,'' Clawson said.

UP NEXT

Wake Forest: Returns home to play host to Coastal Division leader Pittsburgh on Nov. 17.

N.C. State: Visits Louisville on Nov. 17.

---

More AP college football: https://apnews.com/Collegefootball and https://twitter.com/AP-Top25

Copyright 2018 by AP. Any commercial use or distribution without the express written consent of AP is strictly prohibited.