LOUISVILLE, Ky. (AP) Making good on frequent chances at the foul line was satisfying enough for No. 23 Louisville.

The Cardinals also took heart in creating those opportunities with timely takeaways that provided the edge against No. 21 North Carolina State.

Christen Cunningham scored 17 points with five critical free throws in the final 2 1/2 minutes, and Malik Williams added a pair from the line for 14 points to help Louisville outlast the Wolfpack 84-77 on Thursday night.

Back in the Top 25 for the first time since early last season, the Cardinals (14-5, 5-1 Atlantic Coast Conference) needed scoring from everyone down the stretch to earn their fourth consecutive victory. They succeeded at the foul line, making 24 of 29 and closing the game by sinking 9 of 10 to win a tight matchup against the Wolfpack (15-4, 3-3).

Ryan McMahon's two makes with 46 seconds remaining provided a 79-75 lead before Cunningham and Williams each made their two shots for an eight-point edge. Cunningham made 1 of 2 with 11.2 seconds left for the final margin.

''We feel very fortunate to get to the line 29 times,'' Louisville coach Chris Mack said. ''We felt if we were strong with the ball we could get to the line.''

The Cardinals were certainly stout getting the ball when they had to, perhaps the biggest key in surviving the Wolfpack.

They scored 37 points off the Wolfpack's season-high 23 turnovers, the last of which was Braxton Beverly's errant pass that went out of bounds with 38 seconds left. That led to Cunningham's two free throws five seconds later to make it 81-75 before Williams was fouled grabbing a rebound leading to his made shots.

''It was just making the commitment to the defensive end, and we realized we had to get stops playing one-on-one,'' Cunningham said. ''Khwan (Fore) forced (Beverly) to just throw the ball toward the scorer's table with the game on the line. I think it was just locking down and locking in on defense.''

N.C. State coach Kevin Keatts didn't argue the effect of that approach.

''The story of the game was we turned the ball over 23 times, which is really not characteristic of us,'' added Keatts, a former Louisville assistant under Rick Pitino. ''

Jordan Nwora had 13 points and Dwayne Sutton and Steven Enoch each added 10 to complete Louisville's balanced effort. McMahon and Khwan Fore had nine points apiece.

Beverly scored 19 points, Torin Dorn had 18 and C.J. Bryce 15 for N.C. State, which erased deficits of 10 to tie the game before getting close later. But Beverly's two fouls and a turnover in the final minute gave the Cardinals opportunities they converted.

The Wolfpack played a third consecutive game without junior guard Markell Johnson because of a back injury. He traveled with the team, but was in warmups during the game.

''We put him through shoot-around today and I thought he was about 65 percent,'' Keatts added. ''Didn't feel good about it.''

POLL IMPLICATIONS

N.C. State has a chance to regroup against Clemson to stay ranked. Louisville could rise with another ranked win, but how high depends on beating Pittsburgh.

BIG PICTURE

N.C. State: The Wolfpack finished 12 of 27 from long range and seemed to get one when needed to spark a run and tie the game. They also outrebounded Louisville 38-26 with a 30-28 scoring edge in the paint, but faltered in the final minutes in losing for the third time in five games. They were no match for the Cardinals in getting to the line, making 5 of 7.

Louisville: After winning their last three by double digits, the Cardinals used the free throw line to win by seven this time. Their bench also outscored the Wolfpack 21-11, no small feat against a team that entered the contest with a 17.8-point margin in that category.

UP NEXT

North Carolina State: Hosts Clemson on Saturday in the lone season meeting between the schools.

Louisville: Hosts Pittsburgh on Saturday, looking to avenge an 89-86 overtime road loss on Jan. 9.

---

More AP college basketball: https://apnews.com/Collegebasketball and https://twitter.com/AP-Top25

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