RALEIGH, N.C. (AP)Devin Leary threw three of his four touchdown passes in the fourth quarter as North Carolina State’s offense finally got untracked in a 28-13 win over Louisville on Saturday night.

Leary hit Trent Pennix on a 29-yard touchdown pass on the second play of the fourth quarter to push the Wolfpack into the lead. Leary connected with Devin Carter with 5:53 remaining as N.C. State stretched its edge to 21-13. The clinching points came on 10-yard touchdown pass to C.J. Riley with 2:21 to go.

”Love the way we finished the game,” N.C. State coach Dave Doeren said. ”To be able to pad our lead was awesome down the stretch.”

N.C. State (6-2, 3-1 Atlantic Coast Conference), which finished with 44 yards on the ground, had only 189 yards of total offense through three quarters.

”Credit to our defense, they played their tails off the entire game,” Leary said. ”We kind of rallied off that.”

Leary ended up 25-for-36 passing for 317 yards.

”He’s just playing smart,” Doeren said of his quarterback. ”There are times where he’s trying to be a little too perfect, but he’s gutsy.”

So it was largely defense that allowed the Wolfpack to bounce back from a one-point loss a week earlier at Miami. The outcome leaves N.C. State as the closest pursuer to undefeated Wake Forest in the ACC’s Atlantic Division.

”It says a lot about our maturity,” Wolfpack linebacker Drake Thomas said. ”It takes a real strong, mature team to do what we just did.”

The Cardinals managed 55 yards on three fourth-quarter possessions.

”In the fourth quarter, we just didn’t get anything going,” Louisville coach Scott Satterfield said. ”We just didn’t get any rhythm.”

Malik Cunningham was 11-for-28 passing for 219 yards with a touchdown and interception for Louisville (4-4, 2-3). He also gained 76 yards rushing on 18 carries.

”I thought we moved the ball,” Satterfield said. ”We just didn’t score.”

Leary’s first touchdown came on a 19-yard pass to Emeka Emezie in the first quarter.

Cunningham struck with a 76-yard touchdown pass to Jordan Watkins on the last play of the first quarter.

James Turner kicked field goals from 42 and 31 yards for the Cardinals, the latter closing the gap to 14-13 with 9:51 left.

Both teams squandered scoring chances on their first possessions. N.C. State was halted on a fourth-and-1 play from the Louisville 22. The Cardinals then reached the Wolfpack 1 before a penalty and Turner’s miss on a 24-yard field goal attempt.

THE TAKEAWAY

Louisville: Of their three ACC losses, the Cardinals have led in the fourth quarter in two of those and they were tied with Wake Forest in the final minute of the other league defeat.

N.C. State: That’s four consecutive games without a turnover for the Wolfpack. That seemed particularly relevant in this game when any mistake figured to be magnified.

STEP RIGHT IN

Another linebacker moved into a key role for the Wolfpack and it worked out just fine. Thomas made 15 tackles, including a pair of sacks.

”He’s a warrior,” Doeren said. ”Being able to put a guy like Drake in the middle is a nice luxury to have.”

Thomas has filled all three of the Wolfpack’s linebacker spots this year.

N.C. State was in its first full game without linebacker Isaiah Moore, who suffered a season-ending knee injury a week earlier. The Wolfpack lost linebacker Payton Wilson to a season-ending shoulder injury in the second game. Wilson and Moore were the team’s leading tacklers last year.

UP NEXT

Louisville: Home Saturday vs. Clemson.

N.C. State: Final out-of-state trip of the regular season on Saturday at Florida State.

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