"Gary from Chicago" -- the tourist who unknowingly crashed the Oscars with his fiancee -- was in prison as a third striker with a history of stealing ... TMZ has learned.
Gary Alan Coe -- who said he had been in jail for the last 20 years before Sunday night's award show -- was received by California Department of Corrections in 1994 for grand theft exceeding $400, and got locked up again in '97 for petty theft with priors ... and, because it was his third strike, it led to a sentence of 25 years to life with parole.
Law enforcement sources tell us he was resentenced in early 2017 under Proposition 36, and had his 25 year bid reduced to just 6. With pre-sentencing credits and time served ... he walked out a free man last Thursday.
One last detail ... Coe's attorney says he has a prior from 1975 for attempted rape when he was a teenager that required him to register as a sex offender ... but the 20 year sentence was for theft.