Campaigners had a "powerful role" in persuading health bosses to keep open a 24-hour accident and emergency unit at the Royal Glamorgan Hospital, says a senior health official.
There were plans to either close the A&E at night or completely, replacing it with a minor injuries unit.
Serious staff shortages have been tackled and Cwm Taf Morgannwg health board has backed saving it.
Medical director Dr Nick Lyons said community concerns had a big influence.
"It was a humbling and an incredible journey with a local community, not always an easy one - it was quite a bumpy ride at times," he said.
"For me, perhaps the most powerful were some of the illustrations that individual parents, patients and carers gave us, and driving the mountain road, driving around the community, trying to put ourselves in their shoes, thinking how would this would work."
A GP by background, Dr Lyons said it was "incredibly emotional" to listen to people's stories and come up with a recommendation which responded to them.
Why did the health board change its mind?
- Modelling showed replacing the Royal Glamorgan's A&E - which sees an average of 5,300 patients a month - with a minor injuries unit would have put "huge pressures" on the region's other A&Es at Prince Charles in Merthyr Tydfil and Princess of Wales in Bridgend. Those hospitals, he says, would have "struggled to cope" had the unit closed
- Staff recruitment - the Royal Glamorgan was still in trouble without what has been called an "imaginative and aggressive" recruitment campaign. A full-time consultant had left but now there is the equivalent of 2.4 in post, while more doctors have also been hired full time from the locum pool
- The Covid-19 pandemic demonstrated how important the department was in meeting local needs and how the NHS could quickly develop new ways of working and overcome challenges
The A&E unit near Llantrisant was so reliant on single-shift locum doctors late last year that it had to close twice at short notice over the Christmas period due to a lack of cover.
Ambulances had to be re-directed to the region's other hospitals.
Dr Lyons insists the department is now in a much more stable position, with staffing numbers up to a more typical number and no more "Friday afternoon panic" that they wouldn't have enough cover for the weekend.
Medical staff at the hospital also say they now recognise familiar faces on shift and management say this continuity is a big contributor to patient safety.
The complexities around coronavirus and the need for social distancing also means that keeping three A&E units up and running was a factor.
But the response too of staff showed what was possible.
"We've seen teams work in ways that in my 30-odd years in the NHS I've never seen," said Dr Lyons.
"The agility and the imagination and the 'can do' ability and seeing the team support the A&E and work together for our patients has been has been again humbling."
What have campaigners been worried about?
Campaigners organised several protests to argue their case that lives would be put at risk if the department was downgraded.
They were worried about poor transport links between some valleys communities and that other hospitals had been prioritised for investment instead of Royal Glamorgan.
When one health official admitted to Senedd members that no "substantive effort" was made to recruit A&E consultants for five years, they reacted angrily.
Last Thursday, campaigners handed over a 25,000 name petition at the health board's offices in Abercynon in advance of Monday's meeting, when a final decision was made to keep A&E in its current form.
Len Arthur, chairman of the action group, said it was almost "beyond belief" that people power had won but he gave credit for the way thinking had shifted and their arguments had been listened to and now adopted.
"The A&E department has taken a larger role in people's lives over the last 10 years and that's why there's been huge community support," he added.
Sarah Davies, of the Unison union's Cwm Taf branch, said it had "campaigned vigorously" to show the harm and risk of reducing services as well as the negative effect it would have on Prince Charles and Princess of Wales hospitals.
Sara Head, from Beddau, near Pontypridd is a recently retired Paralympian table tennis player.
The 40-year-old competed at London 2012, winning a team bronze, and represented Wales at two Commonwealth Games.
"It's incredibly important to me - I've had some really severe infections and staff have got me well, and it was due to them I got to the Rio Paralympics," she said.
"I was close to having sepsis and at times I was in hospital for six weeks. It was the quick treatment. I feel I'm pretty fit but I'd struggle to reach Merthyr if I couldn't drive.
"They've listened - we hope they'll continue to have that communication with the community because together it can be an amazing place."
Was the plan to downgrade A&E at the Royal Glamorgan a new plan?
In 2014, five south Wales health boards looked to address concerns that maternity care, baby care, children's hospital care and emergency medicine were spread too thinly across too many hospitals.
After a public consultation, health boards and community health councils finally agreed on a series of recommendations.
These included closing A&E at the Royal Glamorgan, but in the intervening period there was little change.
In the Cwm Taf Morgannwg area, consultant-led maternity care has now been centralised at Prince Charles Hospital. But changes to children's hospital care have been repeatedly postponed.
Does this mean it's over?
The health board says "further work" will still be needed to develop appropriate models of care and "mitigate the risks" of ongoing doctor shortages.
It is focusing on a pool of 80 emergency medicine trainees in Wales for further consultant recruitment and aims to bring in five junior clinical fellows by August.