A patient transport service criticised for delays in taking patients to hospital has lost its contract.
Thousands of people signed a petition calling for the NHS to end its agreement with Coperforma in Sussex.
The Clinical Commissioning Group (CCG) which looks after the contract said it would be a "managed transition" to South Central Ambulance Service.
Sussex MP Huw Merriman said Coperforma had "effectively given up the ghost" and handed the contract back.
The firm has signed the necessary legal documents, BBC health correspondent Mark Norman added.
Wendy Carberry, chief executive of High Weald Lewes Havens Clinical Commissioning Group, said: "We are delighted that SCAS has agreed to take over the patient transport service.
"The managed transfer will minimise disruption for patients. And we can start to resolve the situation for staff who have been through a period of uncertainty."
South Central Ambulance Service currently operates ambulances and patient transport services in Berkshire, Hampshire, and Oxfordshire.
Coperforma has been contacted for comment.
Analysis: Mark Norman, BBC health correspondent
There has been a catalogue of problems since Coperforma took over patient transport, with patients left stranded at hospital or at home and missing appointments.
Independent reports have looked into what has gone wrong, but the story has rumbled on and on.
We were told Coperforma had been performing better recently, but presumably it was still not good enough.
Though a contract cannot be taken away from a company unless it is failing completely, I presume the CCG now feels it is legally safe to move on and look for another provider.
Gary Palmer of the GMB union said he was "delighted" by the news but added it meant "six months of very hard work to make sure the transition is done smoothly and our members are protected".
Caroline Ansell, MP for Eastbourne and Willingdon, said: "It was absolutely the right decision and I breathe a sigh of relief common sense has finally prevailed.
"Despite this good news, lessons must be quickly learned from this difficult experience."
Within days of Coperforma starting its contract in April, patients claimed they were suffering delays in reaching appointments.
Lois Wood, a dialysis patient from Crawley, spoke of her relief. "It's what we have been after for months," she said.
Sub-contractors had complained they had also suffered delays with being paid.
One staff member working for sub-contractor Docklands, Steve Barton, said he was "over the moon".
"We are going back in-house, so we won't have wasted time in patient journeys because of logistics. It's going to take time to adjust again but it will benefit everyone eventually."