The justice ministry said the king's intervention in the high-profile case was "an act of compassion and mercy".
Journalist Hajar Raissouni, 28, made a victory sign as she left a prison on Wednesday together with her fiancé, who was also pardoned.
Activists say her case is part of a crackdown on independent reporters.
Moroccan journalist Hajar Raissouni jailed on abortion charges
Could Morocco see the next uprising?
Morocco country profile
Premarital sex and abortions are illegal in Morocco.
Ms Raissouni works for the Akhbar Al-Yaoum daily, a newspaper critical of the authorities.
She was with her Sudanese fiancé as they left a gynaecologist's clinic in the capital Rabat in August. She denied all the charges, saying she had sought treatment for internal bleeding.
Ms Raissouni, who later denounced the case against her as a "political trial", was sentenced in September.
The prosecutor in the case said the circumstances of the journalist's arrest had nothing to do with her work as a journalist, and that the clinic she had visited was under police surveillance on suspicion of carrying out illegal abortions.
The court sentenced her fiancé to a year in prison and her doctor to two years. The doctor's assistant and a nurse at the clinic were also found guilty but were given suspended sentences.
Ms Raissouni told AFP news agency she believed her case had raised a "healthy and useful" debate, and called for gay sex and other jailable offences, such as eating in public during Ramadan, to be to be decriminalised.