By AARON BEARD The Associated Press

RALEIGH, N.C. — Mark Gottfried couldn’t reverse North Carolina State’s two-year slide in time to save his job.

The school announced Thursday that the coach is out after the season. The move comes as a once-promising season continues to unravel, with the Wolfpack struggling to compete in Atlantic Coast Conference play and losing games by lopsided margins. N.C. State has lost six straight games with four of those by at least 24 points, the last coming Wednesday night against 10th-ranked rival North Carolina.

“Mark and I met today to discuss the future direction of our program,” athletic director Debbie Yow said in a statement. “While it has long been my practice to evaluate the body of work at season’s end, in reviewing the overall direction of our program, we believe a change in leadership is necessary moving forward.

“Our focus now remains on supporting our student-athletes and staff over the final weeks of our season.”

A graduate of Mobile’s UMS-Wright school, Gottfried was a starting guard at the University of Alabama and was head coach of the Crimson Tide from March 1998 to January 2009, taking Alabama to heights that included a No. 1 national ranking for two straight weeks, an NCAA Elite 8 appearance and a Southeastern Conference regular season championship. He was head coach at Murray State prior to coming to Alabama and was an assistant at UCLA for eight seasons, including UCLA’s 1995 national championship season.

Gottfried has a 122-82 record with the Wolfpack, including NCAA Tournament trips in his first four years that included two Sweet 16 appearances. But N.C. State has slid to 30-30 over the past two seasons — including 8-24 in Atlantic Coast Conference play — and struggled to maintain continuity amid transfers, players leaving early to pursue professional playing careers, and staff turnover.

Gottfried had declined to talk about his future after Wednesday night’s 97-73 loss to the Tar Heels. N.C. State (14-13, 3-11 ACC) hosts No. 25 Notre Dame on Saturday. The Wolfpack accomplished a major victory this season on January 23, winning at Duke for the first time since 1995.

“It has been a privilege to serve as head coach of N.C. State, and I’m proud of what we have accomplished during my time here,” Gottfried said in a statement Thursday. “N.C. State is a special place, and I appreciate the opportunity to finish the remainder of the season.”

Gottfried got a new five-year deal in 2015 that paid him roughly $2.5 million per season. The contract will require N.C. State to pay him nearly $2.3 million to buy out the final three seasons running through April 2020.

His coaching staff at N.C. State this season includes assistant Orlando Early and Director of Operations, Jeff Dunlap, both of whom served the same roles during parts of his tenure at Alabama.

N.C. State ranked 234th nationally and worst in the ACC in’s adjusted defensive efficiency rankings (107.3 points allowed per 100 possessions) through Wednesday’s games, 61 spots behind the next worst ACC team and better than only four teams from power-5 conferences.