A defense attorney has finally divulged the motive for the 2005 theft of the iconic ruby red slippers from the Judy Garland Museum.

Ahead of his Jan. 29 sentencing, thief Terry Jon Martin has admitted stealing the shoes, which — spoiler alert — were a key part of Garland’s story in The Wizard of Oz.

Martin gave into the temptation of “one last score” after an old mob associate led him to believe the famous shoes must have embedded real jewels to justify their $1 million insured value.

The FBI recovered the shoes in 2018 when someone else tried to claim an insurance reward on them. Martin was charged with the theft last year.

Martin pleaded guilty in October to using a hammer to smash the glass of the museum door and display case to take the slippers.

But a person who Martin tried to sell the shoe to informed him the rubies were glass. Martin got rid of the slippers less than two days after he took them.

Defense attorney Dane DeKrey said in his memo that an unidentified former mob associate tempted Martin to steal the shoes, even though he hadn’t committed a crime in nearly 10 years after his last prison stint.

“At first, Terry declined the invitation to participate in the heist. But old habits die hard, and the thought of a ‘final score’ kept him up at night,” DeKrey wrote. “After much contemplation, Terry had a criminal relapse and decided to participate in the theft.”

Martin is in hospice care with a life expectancy of less than six months.

Garland wore several pairs of ruby slippers during the 1939 musical, but only four authentic pairs are known to remain. The stolen slippers were insured for $1 million, but federal prosecutors put the current market value at about $3.5 million.

Hollywood memorabilia collector Michael Shaw had the shoes on loan to the Garland museum when Martin stole them. Three other pairs worn by Garland in the movie are held by the Academy of Motion Picture Arts and Sciences, the Smithsonian Museum of American History, and a private collector.