Birmingham prison is being brought back in-house permanently after it plunged into crisis under private management.
HM Prison and Probation Service took over the jail from G4S in August.
The unprecedented move was announced at the same time as Chief Inspector of Prisons Peter Clarke published a scathing assessment of the prison, which is one of the largest in the country.
The initial “step-in” was for at least six months, before being extended to the summer.
On Monday, the Government announced that HMPPS has decided, with the full agreement of G4S, to end the contract seven years early.
Prisons Minister Rory Stewart said: “I am confident that HMP Birmingham has made good progress since the ‘step-in’ but to build on this, the prison needs stability and continuity.
“That is why we have mutually agreed with G4S that the public sector is better placed to drive the long-term improvements required and the contract will end.
“Our priority remains the safety of prisoners and staff but this move to restore and consolidate order at one of our most challenging jails will ultimately make sure that we are better protecting the public.”
He stressed the Government still believes in a “mixed economy” of providers, saying some private jails are among the best performing.
“Indeed, G4S itself is running excellent prisons at Altcourse and Oakwood, and this Government believes passionately that private providers should continue to play a crucial role in our system,” Mr Stewart said.
Mr Clarke triggered the “urgent notification” scheme to demand immediate action at HMP Birmingham following an inspection visit last summer.
The chief inspector’s report, which detailed findings prior to the Government’s intervention, revealed that inmates walked around “like zombies” while high on drugs in scenes likened to a war zone.
Prisoners flouted rules without challenge from staff, many of whom were “anxious and fearful” as they went about their duties, the assessment found.
G4S was awarded a 15-year-contract to run the jail in 2011.
The firm will pay £9.9 million to cover additional costs associated with the step-in and essential maintenance works.
G4S custodial & detention services managing director Jerry Petherick said: “HMP Birmingham is an inner-city remand prison which faces exceptional challenges including high levels of prisoner violence towards staff and fellow prisoners.
“We believe that it is in the best interests of staff and the company that management of this prison is transferred to HMPPS and we will work closely with the Ministry of Justice to ensure a smooth transition over the next three months.
“We will continue to deliver high quality services at the other four major UK prisons that we manage and I would like to pay tribute to all of our employees who provide an outstanding service at these prisons, often in a demanding operating environment.”
Mark Fairhurst, national chairman of the Prison Officers Association, said the announcement means HMP Birmingham will be returned to “where it rightfully belongs”.
Editor of The Prisons Handbook for England and Wales, Mark Leech, called the decision “sensible”
Mr Leech said: “I believe that the reasoning behind this decision is that the Ministry of Justice take the view that, rightly or wrongly, G4S cannot be trusted to take back management of the prison without the real risk that it will again descend into chaos and a lack of control.
“In those circumstances its a sensible and pragmatic decision but G4S have recently been named as one of the operators involved in the selection process for operation of the soon to be opened Wellingborough and Glen Parva prisons – this decision must mean their application is subject to exceptional scrutiny.”