The Dudley Group NHS Foundation Trust was prosecuted by the Care Quality Commission (CQC) following two separate incidents in which a mother-of-six and a 14-year-old girl, who were both suffering from sepsis, died after being "exposed to significant risk of avoidable harm".
Natalie Billingham, 33, died at Dudley's Russells Hall Hospital from multiple organ failure caused by a severe infection in March 2018.
A two-day hearing at Wolverhampton Magistrates' Court was told teenager Kaysie-Jane Robinson, who had cerebral palsy, died in the same month after an inaccurate "early warning score" meant a sepsis screening tool was not triggered.
The CQC said the care both patients received was undermined by the trust's failure to address known safety failings, which had been repeatedly raised in the months before the deaths.
The trust admitted two breaches of the 2008 Health and Social Care Act.
Passing sentence on the trust, District Judge Graham Wilkinson fined it £2,533,332 and ordered it to pay a £38,000 contribution to the costs of the prosecution.
Mr Wilkinson, who conceded that improvements in care had been made since the "dark days" of 2018, said: "We have all now heard and been deeply moved by the victim personal statements.
"To hear direct from the mothers of both victims and to witness first-hand both their distress and bravery is something that I doubt any present will ever forget.
"I have been informed that it is the first prosecution ever of any trust for failings within an emergency department.
"One of the most significant features of the case when considering culpability was that the trust had been inspected by the CQC in a series of unannounced visits during the months preceding this tragedy.
"What was found on each occasion clearly shocked the inspecting team of healthcare professionals.
"It was against this backdrop that Natalie and Kaysie-Jane were failed by the trust.
"It is clear that had the trust reacted to the concerns of the CQC in a timely fashion, then this double tragedy may not have unfolded.
"It failed to act swiftly and decisively to the concerns raised by the CQC - those concerns themselves warned that lives and patient safety were at risk.
"Having reached that conclusion, this places the case for sentencing purposes in... the very highest category for such cases."
District Judge Wilkinson conceded that the trust had taken very significant steps to learn from the events of 2018.
Descriptions of the trust as a "failing organisation" were no longer appropriate, the judge said, adding: "It is clear that the trust has improved since the dark days of 2018 and continues to improve.
"In this case (the defendant) is our most revered of institutions, the NHS.
"Each of us have benefitted from its existence at various stages of our lives and even before the pandemic its place in our society was assured. Now we recognise its worth and the phenomenal work done by its staff with even greater admiration.
"However, whatever I may feel on a personal level I am required as a judge to apply the law dispassionately and without favour or prejudice."
In a statement issued after Friday's hearing, the trust's chief executive, Diane Wake, said: "We are deeply sorry that our care did not meet the standards Kaysie-Jane, Natalie and their families had a right to expect.
"Today's hearing was an important step for the families in a long process. We want to apologise and offer our sincere condolences again to Kaysie-Jane and Natalie's families.
"Although it will offer the families little comfort, we have learned from the failings that led to Kaysie-Jane and Natalie's tragic deaths and made fundamental changes in the way our care is provided."
The changes have included significant improvements in electronic observations, including the introduction in November 2018 of electronic sepsis monitoring, which shows when a patient is deteriorating and reduces the risk of human error.
The trust said all its healthcare staff have mandatory sepsis training, and over the last three years it had been "open and transparent" with regulators about what went wrong, what it had learned and what actions had been taken to invest in and improve services.
But Ms Wake said the trust does not accept that it did not react to the concerns raised.
"The trust has an independent report that says the trust took urgent and significant steps to address the concerns and were already aware of and making improvements before the unannounced visits," she said.
The court heard on Thursday how Ms Billingham was admitted to hospital with numbness in her right foot on February 28 2018 and died on March 2 of organ failure caused by a "time critical" infection.
The court was told she was initially thought to have a deep vein thrombosis after a three-minute triage that failed to identify "disordered" observations.
Kaysie-Jane, who was admitted to Russells Hall on March 4 and died six days later after being transferred to another hospital, was initially believed to have gastroenteritis.