Siti Aisyah smiled as she was ushered through a pack of journalists and into a car outside the court, where she had been on trial alongside a Vietnamese woman for the murder of Kim Jong Nam at Kuala Lumpur airport in February 2017.
"I feel happy. I did not know this will happen. I did not expect it," said the 27-year-old, who was wearing a red headscarf.
It was a surprise move as the Shah Alam High Court, outside Kuala Lumpur, had been due only to hear Vietnamese accused Doan Thi Huong testify on Monday.
Huong's lawyer said she was "traumatised" that only Aisyah had been released, and the court agreed to adjourn the Vietnamese suspect's testimony to allow her legal team to apply for her murder charge to be dropped.
The women had always denied murder, saying they were tricked by North Korean spies into carrying out the Cold War-style hit using VX nerve agent and believed it was a prank for a reality TV show.
Their lawyers presented them as scapegoats, saying that authorities were unable to catch the real killers. Four North Koreans -- formally accused of the murder alongside the women -- fled Malaysia shortly after the assassination.
The trial, which began in October 2017, had been due to resume Monday with the defence stage of proceedings after a break of several months.
But at the start of the hearing, prosecutor Muhammad Iskandar Ahmad requested that the murder charge against Aisyah be withdrawn and that she be given a discharge, without providing a reason.
The judge agreed to the request for a discharge not amounting to an acquittal, and ordered Aisyah's immediate release. This means Aisyah has not been formally cleared of the charge and could in theory be arrested on suspicion of Kim's murder again.
Aisyah's lawyer Gooi Soon Seng said he was grateful for the decision: "We still truly believe that she is merely a scapegoat and she's innocent".
- Huong 'traumatised' -
But speaking to reporters through an interpreter in court, Huong said she felt "terrible" about her own position. "I do not know what will happen to me now. I am innocent -- please pray for me," she said. Huong's lawyer, Hisyam Teh Pok Teik, added that she was "traumatised by what happened in court".
In the northern Vietnamese province of Nam Dinh, her father Doan Van Thanh expressed shock his daughter was still behind bars and called for her release.
"Why did they release the Indonesian girl without releasing my daughter?" he told AFP.
It was not immediately clear why Aisyah was released and not Huong, but Indonesia often makes concerted diplomatic efforts to get its citizens on death row overseas released.
"There has been a long process to free her... since she was detained," Indonesian foreign ministry spokesman Arrmanatha Nasir told reporters in Jakarta.
Indonesian ambassador to Malaysia Rusdi Kirana told reporters outside court he was pleased about the release of Aisyah, who was taken to the Indonesian embassy in Kuala Lumpur, and that she would be flown home as soon as possible.
Prosecutors had presented their case in the first stage of the trial. Witnesses described how the victim -- the estranged half-brother of Kim Jong Un and once seen as heir apparent to the North Korean leadership -- died in agony shortly after being attacked.
CCTV footage seen in court during the trial showed the suspects rushing to separate bathrooms in the airport after the murder, before leaving in taxis, and prosecutors likened it to something out of a James Bond movie.
But their lawyers argued the four North Koreans were the masterminds, and provided the women with poison on the day of the murder before fleeing.
In August, a judge ruled there was sufficient evidence the suspects had engaged in a "well-planned conspiracy" with the North Koreans to murder Kim, and ordered that the trial continue to the defence stage.
South Korea has accused the North of ordering the hit, which Pyongyang denies.
Malaysia had been one of the nuclear-armed North's few allies but the assassination badly damaged ties, and led to the countries expelling each other's ambassadors.
A murder conviction carries a mandatory penalty of death in Malaysia. The government has vowed to abolish capital punishment for all crimes, although parliament still needs to vote on changing the law.