The criminal trial of Donald Trump didn’t have to end this way.

The prosecution’s case had flaws that couldn’t be wallpapered over even with weeks of testimony, over 200 exhibits and a polished and persuasive presentation by Alvin Bragg, the Manhattan district attorney, and his team. If Mr. Trump’s lawyers had played their cards right, they most likely would have ended up with a hung jury or a misdemeanor conviction.

The defense lost a winnable case by adopting an ill-advised strategy that was right out of Mr. Trump’s playbook. For years, he denied everything and attacked anyone who dared to take him on. It worked — until this case.

I have practiced criminal law for over 20 years, and I have tried and won cases as both a federal prosecutor and criminal defense attorney. I’ve almost never seen the defense win without a compelling counternarrative. Jurors often want to side with prosecutors, who have the advantage of writing the indictment, marshaling the witnesses and telling the story.

The defense needs its own story, and in my experience, the side that tells the simpler story at trial usually wins.

Instead of telling a simple story, Mr. Trump’s defense was a haphazard cacophony of denials and personal attacks. That may work for a Trump rally or a segment on Fox News, but it doesn’t work in a courtroom. Perhaps Mr. Trump’s team was also pursuing a political or press strategy, but it certainly wasn’t a good legal strategy. The powerful defense available to Mr. Trump’s attorneys was lost amid all the clutter.

At the beginning of the trial, Mr. Trump’s team had a clear path to victory. He was charged with 34 counts of falsifying business records related to the cover-up of a $130,000 hush-money payment that was made to the porn star Stormy Daniels. Yet the only direct evidence of Mr. Trump’s knowledge was the testimony of Michael Cohen — who has pleaded guilty to lying to Congress and charges of bank fraud, tax evasion and campaign finance violation — who hates Mr. Trump and makes money off his public commentary on Mr. Trump’s legal woes.