Jeremy Hunt was ordered by a judge to delete a "highly inappropriate" tweet commenting on a manslaughter trial while it was still going on.
Hunt sent the tweet two weeks ago during the trial of an NHS trust and an anaesthetist over the death of a mother in surgery in 2012.
Maidstone and Tunbridge Wells NHS Trust was accused of corporate manslaughter over the death of schoolteacher Frances Cappuccini, 30, in the first prosecution of a health service body since the offence was introduced in 2008.
Locum consultant anaesthetist Errol Cornish, 68, was accused of gross negligence manslaughter over his role in the care of the mother-of-two, who died after postnatal surgery at Tunbridge Wells Hospital in Pembury, Kent, in October 2012.
On the second day of the trial, Hunt tweeted a link to a news report about it, calling it a "tragic case from which huge lessons must be learned".
A judge said the message could have prejudiced jurors' views of case, which could amount to contempt of court. When they are sworn in, jurors are reminded to avoid reading media reports of trials or doing their own research.
Mr Justice Coulson dryly noted that there are “no professional lawyers” in the House of Commons and ruled the tweet had to be immediately removed.
He said: “It is highly inappropriate for anybody to pass comment which might be said to know the result of a trial before that result is known.
"I suppose, potentially, in a very serious case, it could be regarded as a contempt of court. I would hope that everybody would know that. Sadly, these days, many people in public life don’t know that.
“I think it’s right that there be no future comment about possible results in this case until it is known. That includes the tweet from the present health secretary that I’ve been shown.
"These days it is hard to have the word ‘tweet’ without ‘ill-advised’ before it.”
The judge's order for Hunt to delete can only be reported now, after the trial collapsed this week.
The Huffington Post UK has approached The Department for Health for comment.
Mr Justice Coulson instructed the jury at Inner London Crown Court to acquit both defendants, just over two weeks into their trial, having ruled on Wednesday that they had no case to answer, The Press Association reports.
In his ruling, he praised the Cappuccini family's "dignity" during the trial and said: "There is no question that Frances Cappuccini should not have died at the trust hospital on October 9.
"It's inevitable that her family will want to know why she died and hold someone to account."
But the judge outlined a series of flaws in the prosecution case, including evidence that showed some of locum Dr Cornish's actions had been "about as far from a gross negligence manslaughter case as it is possible to be". He also branded some of the arguments against the trust as "perverse".
Mrs Cappuccini's widower Tom, who had attended court throughout the trial, was not present as the foreman of the jury of 10 women and two men returned formal not guilty verdicts on the order of the judge.
Mr Justice Coulson told them that he had agreed with arguments from the defence barristers that neither had a case to answer.
He said: "On my direction, as a matter of law, both defendants are not guilty."
Mrs Cappuccini lost around four pints of blood after her second son Giacomo was born by Caesarean section at the hospital in Kent.
She was subsequently operated on for a postpartum haemorrhage but never woke up from the anaesthetic.
She went into cardiac arrest just over three hours after the operation had finished on October 9, 2012, and died at 4.20pm.
The trial heard that a second anaesthetist, Dr Nadeem Azeez, 53, was primarily responsible for Mrs Cappuccini's care, but did not face a trial alongside them because he had returned to his native Pakistan.Suggest a correction