The Bahraini Shiite mother, who also holds Danish nationality, had been convicted of insulting King Hamad by ripping up a picture of him, and had chosen to keep her 17-month-old son with her in jail.
Judicial authorities ordered "the suspension of the sentence" for Khawaja and another defendant identified as Irena Bogotova who had been jailed with her four-year-old son, Abdulrahman al-Sayed said in a statement.
They were released "considering their humanitarian situation and in the interests of their children," he said.
Zainab al-Khawaja is the daughter of prominent rights activist Abdulhadi al-Khawaja, who is serving a life sentence for plotting to overthrow the Sunni regime.
Also Read
The Gulf Centre for Human Rights (GCHR) has said Khawaja was jailed for three years and one month on charges including tearing up the monarch's picture and insulting a police officer.
Her sister Maryam, co-director of the GCHR, confirmed on Twitter that Khawaja "is officially out and on her way home to her (other) children".
The foreign ministry said earlier in May Khawaja would be freed with another foreigner for "humanitarian" reasons, adding that their release was the result of a follow-up into the situation of inmates with foreign citizenship held in criminal cases.
Tiny but strategic Bahrain, home base of the US Navy's Fifth Fleet, remains deeply divided after authorities crushed a month-long, Shiite-led uprising that called for reforms in March 2011.
Dozens of activists are serving lengthy jail terms, including Sheikh Ali Salman -- the leader of Bahrain's main opposition bloc Al-Wefaq.
An appeals court yesterday increased his jail term on charges of inciting violence to nine years from the original four, a judicial official said.