Greg Hardy just dodged a bullet ... he will NOT go to prison in his cocaine possession case, TMZ Sports has learned.
The ex-NFL star -- and current MMA fighter -- has struck a plea deal with prosecutors in Dallas in which his felony drug possession charge was reduced to a misdemeanor.
As a result, Hardy was sentenced to 2 years unsupervised probation along with other fines ... a clerk at the Dallas County Court tells us.
As we previously reported, Hardy was arrested on Sept. 25 when cops pulled over a 2010 Dodge Challenger for turning without signaling -- and during the bust, found a baggie of the white stuff in Hardy's brown Louis Vuitton wallet.
Officials say the coke weighed in at .7 grams.
Hardy was indicted on 1 count of felony possession of a controlled substance -- and faced up to 2 years in prison if convicted.