RALEIGH, N.C. (AP) — Larry Fedora overcame years of NCAA trouble at North Carolina — from inherited scholarship reductions to an academic case that hovered over recruiting — to help the Tar Heels put up big offensive numbers and win an Atlantic Coast Conference division championship.

But Fedora never could halt a startling two-year downturn for his program, and that ultimately cost him his job.

The school announced Sunday that Fedora is out after seven seasons. The decision came the day after an overtime loss to rival North Carolina State that dropped the Tar Heels to 2-9 and concluded with a brawl between the teams in the end zone after the Wolfpack scored the winning touchdown.

Fedora's exit completes a swift fall . UNC matched a program record with 11 wins and a trip to the ACC championship game in 2015. UNC slipped to 8-5 the next season and then went 5-18 over the past two seasons marred by injuries, inexperienced players and close losses.

In a statement, Fedora said coaching at UNC was a "great honor" and called the past two seasons "challenging and heartbreaking." He said that he was "extremely disappointed" that he would no longer coach the Tar Heels, adding: "I hate that it had to end this way."

"I wanted the opportunity to fix this," Fedora said. "I wanted to make the changes necessary to win again. I also understand this business. I understand that you don't always get the time you want to turn things around. I respect the administration's position and understand their actions."

Fedora agreed to a new seven-year deal after the 2015 division title. According to contract terms through the 2022 season, the change will cost UNC more than $12.4 million, with about $12 million of that distributed over the coming four seasons. That number could drop if Fedora takes another job.

"This was not an easy decision because of the deep affinity I have for Larry," athletic director Bubba Cunningham said in a statement of his first major hire at UNC. "It simply is time to take our football program in a new direction."

Fedora arrived in Chapel Hill to take over a program near the conclusion of an NCAA investigation into improper benefits and academic misconduct. He inherited scholarship reductions and a one-year postseason ban, which kept the Tar Heels out of the ACC championship game in his debut season in 2012.

The ruling was supposed to conclude the NCAA issues, though the case spawned an offshoot probe into a more serious concern: nearly two decades of irregular courses in an academic department popular with athletes across numerous sports. That case lingered another five years, and even led to five top-level NCAA charges, before reaching a no-penalty conclusion in October 2017.

Still, Fedora got the Tar Heels to two bowl games before the breakout 2015 campaign. But the slide began in November 2016, when a 7-2 UNC team ranked 15th nationally and led by eventual No. 2 overall NFL draft pick Mitch Trubisky lost at struggling Duke.

Starting with that loss, UNC has lost 21 of 27 games. Three wins came against FCS opponents, while the only two wins in 18 ACC games came against Pittsburgh.

There were numerous factors in UNC's slide. Trubisky left a year early for the NFL and the Tar Heels never found a reliable replacement. There was significant coaching turnover, notably with the departures of offensive coordinator Seth Littrell in December 2015 to become North Texas' head coach and defensive coordinator Gene Chizik when he left coaching in early 2017.

There were also a long line of injuries in 2017, and then things started badly this year when 13 players faced suspensions for selling team-issued shoes — which followed Fedora's much-criticized comments on football's ties to the degenerative brain disease CTE.

On the field, UNC lost five games by one-possession margins this year.

"We appreciate all that Larry Fedora has done for us over the last seven years — coming to Carolina in the midst of an NCAA case and bringing stability to our football program when we most needed it," Cunningham said. "Despite injuries, despite setbacks and hardships, Larry never made excuses. He focused his teams on overcoming adversity, and I deeply respect the way he persevered and led our program each day with integrity through some tough times."

Copyright 2018 The Associated Press. All rights reserved. This material may not be published, broadcast, rewritten or redistributed.

More From KSOO-AM / ESPN Sioux Falls