Greg McElroy explains that it makes sense for both and Gary Andersen and Oregon State to part ways at this point. (0:45)

Gary Andersen is out as the football coach at Oregon State, effective immediately.

The university announced Monday that the parties have mutually parted ways and agreed to release each other from the remaining contractual obligations. Andersen was under contract through the 2021 season.

Assistant coach Cory Hall has been named the interim coach.

Gary Andersen was under contract at Oregon State through the 2021 season. Brian Murphy/Icon Sportswire

Andersen signed a contract extension in December and had more than $12.4 million remaining on the deal. Oregon State owed him $883,332 for the rest of this season, $2.75 million for 2018, $2.85 million for 2019, $2.95 million for 2020 and $3.05 million for 2021.

"After many discussions with [athletic director] Scott [Barnes], waiving my contract is the correct decision and enables the young men and the program to move forward and concentrate on the rest of this season," Andersen said in a statement. "Coaching is not about the mighty dollar. It is about teaching and putting young men in a position to succeed on and off the field. Success comes when all parties involved are moving in the same direction."

After two years as the coach at Wisconsin, where he went 19-7, Andersen made the surprising jump to Oregon State before the 2015 season to replace Mike Riley. He inherited a team devoid of talent but seemingly had the program heading in the right direction coming into the season. The Beavers improved from 2-10 in his first season to 4-8 last year but are just 1-5 to this point with the lone victory coming against FCS Portland State at home.

Against FBS opponents, the Beavers' narrowest margin of defeat came on Saturday in a 38-10 loss to USC.

"This is an exceptionally difficult time for me, personally and professionally," Barnes said in a statement. "I have known Gary for many years and respect him highly as a person, my friend, a head football coach and an incredible leader of young men. The timing of this is very difficult; however it is the best for all involved."

Andersen was the head coach at Utah State from 2009 to 2012, where he compiled a 26-24 record, including an 11-2 season in his final year that propelled him to the Wisconsin job.

The Beavers host Colorado on Saturday.

ESPN's Mark Schlabach contributed to this report.