On Sept. 30, a Moroccan judge found female journalist Hajar Raissouni, 28, guilty of having premarital sex and obtaining an abortion. But on Wednesday, the Moroccan king pardoned Raissouni, and she was to walk free “in the coming hours,” according to the justice ministry.

Morocco's King Mohammed VI pardoned the reporter to "preserve the future of the couple, who wanted to establish a family in line with our religious and legal precepts, despite the error they made," according to AFP.

The judge had sentenced Raissouni and Rifaat al-Amin to one year’s jail time, and Dr. Jamal Belkeziz, accused of performing the abortion, to two years in prison. Both the doctor and Raissouni’s fiancé were pardoned Wednesday as well.

Raissouni denied having the procedure and claimed she was married to her Sudanese fiancé under Islamic law -- they had married in a religious ceremony but had not yet arranged a legal marriage contract.

Moroccan journalist Hajar Raissouni leaves the prison in Sale, near the capital Rabat, Morocco, on Wednesday.  (Reuters)

Raissouni, who works for independent newspaper Akhbar al-Yaoum, was arrested along with al-Amin as they were leaving a gynecologist’s office in the Moroccan capital of Rabat on Aug. 31. The defendants said that Raissouni was seeking treatment for a blood clot, though authorities said she was being arrested as part of an abortion sting against the clinic where she’d been seen. Abortion, along with sex out of wedlock, is illegal in the predominantly orthodox Muslim country.

The case drew the ire of activists across the country and world, and many protested Raissouni’s conviction and called it a threat to women’s rights.  Activists said Raissouni had clearly been targeted for her place of employment, as al-Yaoum is one of Morocco’s few independent newspapers and is often critical of the state.

While in custody, Raissouni said she was mostly interrogated about her work as a journalist, her colleagues at the paper and family members. Raissouni’s uncle Suleyman Raissouni is editor-in-chief.

"If this verdict confirms anything, then it would be that this arrest was (an act of) revenge against Hajar and her editorial family at the newspaper," he said.

Raissouni said police had taken her for medical checks against her will, an action her lawyers described as torture.

In court, the prosecutor denied any wrongdoing on behalf of authorities and said the case had nothing to do with Raissouni’s work as a journalist.

The Associated Press contributed to this report.