(CNN) -- A 30-day rape sentence given to a teacher who admitted to raping his 14-year-old student may be illegal, according to the Montana judge who imposed it.
The judge scheduled a new hearing for Friday.
"The Defendant shall be present at argument as the Court, if necessary and appropriate, will amend the mandatory minimum portion of the sentence," read a court order filed Tuesday.
It appears the mandatory minimum is two years, not 30 days, the order said.
"In this Court's opinion, imposing a sentence which suspends more than the mandatory minimum would be an illegal sentence," it continued.
The case drew widespread attention when District Judge G. Todd Baugh imposed the 30-day sentence on Stacey Dean Rambold and made controversial comments about the victim, saying she "seemed older than her chronological age."
Scott Twito, a prosecutor with the Yellowstone County attorney's office, did not immediately return a call for comment.
In a memo from his office to the Montana attorney general's office, attorneys had argued the relevant statute was "misapplied and the minimum sentence that could be imposed in Rambold's case was two years" -- anticipating the judge's Tuesday order.
Rambold admitted to raping the girl while he was her teacher at her high school.
Cherice Moralez was 14 at the time. She took her own life shortly before her 17th birthday.
The case began in 2008 when Cherice was a student at Billings Senior High School and Rambold, then 49, was a teacher.
School officials learned of the relationship, and Rambold resigned.
Authorities charged Rambold with three counts of sexual intercourse without consent.
As the case wound its way through the legal system, Cherice committed suicide. She was a few weeks shy of her 17th birthday.
With her death, prosecutors entered into what is known as a "deferred prosecution agreement" with Rambold.
This meant that all charges against Rambold would be dismissed if he completed a sex-offender treatment program and met other requirements. One of them was to have no contact with children.
Rambold admitted to one of the rape charges.
But the ex-teacher fell short of the agreement.
"He had some contacts with nieces and nephews in a family setting and other adults were present," Baugh said.
He also had relationships with women that he didn't tell his counselors about.
"That is a violation from his deferred prosecution so he was dropped from the plan," said the judge.
As a result, the case was revived in December 2012.
At a hearing last month, Baugh ruled that Rambold's infractions weren't serious enough.
"He made some violations of his treatment program," he said. "They were more technical and not the kind you would send someone to prison for."
He sentenced Rambold to 15 years in prison. Then, he suspended all but 31 days of the sentence, according to the Yellowstone County District Court.
The judge gave Rambold credit for one day he spent in jail.
Incredulous at what had happened, the victim's mother, Auliea Hanlon, shouted at the court, "You people suck."
"She wasn't even old enough to get a driver's license," Hanlon said in a statement released by her attorney. "But Judge Baugh, who never met our daughter, justified the paltry sentence saying she was older than her chronological age. I guess somehow it makes a rape more acceptable if you blame the victim, even if she was only 14."
CNN's Amanda Watts, Paul Vercammen and Kyung Lah contributed to this report.