After proclaiming his innocence for nearly 20 years, Xavier Walker Wednesday was set to walk out of the Cook County Jail a free man after prosecutors dropped all charges against him in a 2000 murder case.

Walker, 39, was 19 years old when he was arrested for the murder of Mark Madjak during a robbery in West Garfield Park. He told the first lawyer he saw that police had pummeled him into making a confession, but that he also always protested that he was innocent.

But Walker and co-defendant Jovanie Long both ended up convicted of the killing, with Walker getting a 35-year prison sentence, and Long 45 years.

At a July hearing, prosecutors with the State’s Attorney’s Conviction Integrity Unit agreed to vacate Walker’s conviction based on the failure of his trial attorney to introduce photographs that showed injuries Walker’s then assistant public defender had noticed at his bond hearing, or to call any of the multiple alibi witnesses, Assistant Public Defender Harold Winston said.

But prosecutors did not drop the case, and Winston and co-counsel Julie Koehler had gone to court Wednesday expecting to grill witnesses in a bid to have Judge Alfredo Maldonado toss Walker’s confession. Instead, prosecutors dropped the case.

Koehler’s eyes welled with tears as she explained — over the joyous whoops of a half-dozen of Walker’s relatives — that Walker would go free. The hearing was over so quickly Walker’s father, who had attended every hearing in his son’s case over two decades, was still parking his car.

“This was a total surprise,” Koehler said in the lobby outside Maldonado’s courtroom.

“[Walker] was just so obviously innocent. He was just a kid. Every time I would look at his parents, I would think, ‘I have to get their boy home.’”

Leaning on a cane, Quillitene Walker said she was overwhelmed at the thought of having her son at home for Christmas for the first time in two decades.

“From the bottom of my heart, I always believed that God would make a way for my son to be here,” the 74-year-old said. “We just want to celebrate with our son.”