It began in September 2005 with a man in a hospital bed, just out of a coma but floating on a lake of morphine for the pain from the bullets he took in the stomach during a push-in robbery. A detective asked the man to check his cellphone records because the robbers had made some calls before he was shot.

The victim pointed to a number he didn’t recognize.

In fact, it was identical to a number the man himself called regularly, except that the last two digits were transposed. That is: It was a misdial by the victim, not a call by a criminal. But it set off a hunt that led, ultimately, to 40-year prison terms for two young women who had nothing to do with the crime.

Unwinding that calamity took every bit of eight years and four months. Last Thursday, a judge ordered the release from state prison of Latisha Johnson, who turned 27 on Saturday, and Malisha Blyden, 32. Bronx prosecutors agreed that a team of dogged appeals lawyers had proved their innocence.

Like plane crashes that are almost always caused by multiple failures, the case of Ms. Johnson and Ms. Blyden is a study in a cascade of mistakes, each one reflecting what came before and forcing what followed.