The case that led to Brodie's downfall began later in 1788 when he organised an armed raid on an excise office in Chessel's Court on the Canongate. Brodie's plan failed. On the same night, Brown approached the authorities to claim a King's Pardon, which had been offered after a previous robbery, and gave up the names of Smith and Ainslie (initially saying nothing of Brodie's involvement). Smith and Ainslie were arrested, and the next day Brodie attempted to visit them in prison, but was refused. Realising that he had to leave Edinburgh, Brodie escaped to London and then to the Netherlands, intending to flee to the United States, but was arrested in Amsterdam and shipped back to Edinburgh for trial.
The trial of Brodie and Smith started on 27 August 1788. At first there was no hard evidence against Brodie, although the tools of his criminal trade (copied keys, a disguise and pistols) were found in his house and workshops. But with Brown's evidence and Ainslie being persuaded to turn King's Evidence, added to the self-incriminating lines in the letters he had written while on the run, the jury found Brodie and Smith guilty.
Brodie and Smith were hanged at the Old Tolbooth in the High Street on 1 October 1788 before a crowd of 40,000. According to one tale, Brodie wore a steel collar and silver tube to prevent the hanging from being fatal. It was said that he had bribed the hangman to ignore it and arranged for his body to be removed quickly in the hope that he could later be revived. If so, the plan failed. Brodie was buried in an unmarked grave at St. Cuthbert's Chapel of Ease in Chapel Street. However, rumours of his being seen in Paris circulated later and gave the story of his scheme to evade death further publicity.