Lagos, Nigeria CNN  — 

Nigerian professor Richard Akindele, accused of demanding sex from a female student, was sentenced to prison on Monday.

Akindele was convicted after pleading guilty to four criminal charges, including demanding gratification from a student and sexual coercion of a student, according to court documents seen by CNN.

Akindele had pleaded not guilty to the charges in earlier court appearances at the Federal High Court in Osogbo, southwest Nigeria. However, he changed his plea during his third appearance in court on Monday.

Akindele was sentenced to two years in prison for demanding sexual benefits from student Monica Osagie, two years for soliciting sexual benefits to improve her marks, one year for falsifying his age, and one year for altering evidence. The judge said his sentences would run concurrently, so he will serve two years.

Osagie, 23, was not in court on Monday but her lawyers told CNN she consented to a plea bargain made by Akindele, a requirement under Nigerian law.

The case against Akindele gained momentum after Osagie’s exclusive interview with CNN.

Osagie said she secretly taped a phone conversation with Akindele to gather evidence against him.

Akindele was fired by Obafemi Awolowo University for sexual misconduct one month after the interview and the Nigerian Senate launched an investigation into the issue of sexual harassment in universities.

Nigeria’s anti-corruption agency, ICPC, also started criminal proceedings, which led to his conviction Monday.

Akindele’s lawyers negotiated a plea bargain with federal prosecutors and they deliberated for four hours before Justice Maureen Onyekenu reached a judgment on Monday. The judge rejected the terms of the plea bargain, including a suspended sentence, community service and an option of a fine.

The professor needed to be “taught a lesson” to serve as a deterrent to those who abuse their authority, Onyekenu told the courtroom.

She said accepting the bargain would have downplayed the trauma victims of sexual harassment face in universities.

“I know the mental torture many of our female students have been subjected to by the likes of the respondent.

“The adverse effect of such action is huge. Many of his like have been awarding marks to those students that are ready to warm their beds, thereby releasing half-baked graduates into the society,” Onyetenu said.

A lawyer for Akindele did not immediately respond to a request for comment.

Akindele’s sentence was hailed by women’s rights campaigners and prosecutors pursuing the case.

“The ripple of the outcome of this case will be felt positively for years to come,” ICPC spokeswoman Rasheeda Okoduwa said.

“It’s a clear message to all those who harass students to stop it. If they don’t, we will come after them with the law. This brings some measure of relief to students in the system if this harassment occurs,” she said.