The Council for the Advancement of the South African Constitution (Casac), Corruption Watch and Freedom Under Law (FUL) had approached the high court to set aside the settlement agreement between former prosecutions boss Mxolisi Nxasana and President Jacob Zuma, reached in 2015, that saw him receive R17 million to vacate his office.
They wanted Nxasana to be reinstated and to give back the R17 million "golden handshake".
"The appointment of Shaun Abrahams as the NDPP is reviewed, declared invalid and set aside," Mlambo said.
Mlambo also ruled that a new prosecutions boss must be appointed within 60 days, as it would not be just to reinstate Nxasana, and that this appointment must be made by Deputy President Cyril Ramaphosa.
* This is a developing story.
Additional reporting by Reuters