SHAH ALAM, Malaysia — An Indonesian woman who was on trial in the 2017 airport killing of Kim Jong-nam, the estranged half brother of the North Korean leader Kim Jong-un, was freed on Monday after more than two years in custody.

The defendant, Siti Aisyah, 27, will be allowed to leave Malaysia and return to Indonesia after prosecutors in the case withdrew the murder charge against her without explanation.

“I am surprised and very happy,” Ms. Siti told reporters as she left the courthouse.

According to Ms. Siti’s attorney, Gooi Soon Seng, Ms. Siti departed later on Monday for Jakarta, the Indonesian capital, on a private jet with Rusdi Kirana, Indonesia’s ambassador to Malaysia and a co-founder of the Indonesian budget airline Lion Air. They landed in the late afternoon.

The fate of a second suspect in the case, Doan Thi Huang, 30, of Vietnam, remained uncertain. She had been scheduled to begin testifying on Monday for the first time. But after the dismissal of the case against Ms. Siti, the trial was put on hold so that the defense could seek dismissal of the charges against Ms. Doan. The court is scheduled to reconvene on Thursday.