EXCLUSIVE

UFC superstar Nick Diaz is headed for the slammer -- but not for long ... after cutting a pretty badass deal in his TWO DUI cases ... TMZ Sports has learned.

As we previously reported, the 31-year-old fighter was arrested for DUI in Lodi, CA back in September ... just one year after he was previously popped for DUI in the same city.

Diaz was facing real jail time if convicted in both cases -- but struck a sweet plea deal with prosecutors in which he pled no contest to DUI with .08 or higher, and in exchange 3 charges were thrown out ... including the second DUI.

He was sentenced to 2 days in jail -- and gets credit for 1 day served ... so he'll be a free man in no time (props to Nick's lawyer).

In addition to the jail time, Diaz also got 3 years of informal probation and must complete a DUI educational course.