Racing legend Al Unser Jr. won't have to spend any more time behind bars for his wild DUI arrest back in May ... 'cause TMZ Sports has learned he cut a sweet deal with prosecutors this week.
The 57-year-old was driving on an Indiana highway back on May 20 when police say they caught him going 59 MPH in a 45.
Cops say they saw his car swerving when they followed him to pull him over ... and when they stopped him, they say he wreaked of booze and showed all the signs of being drunk.
In fact, officers say he was so wasted, when they asked him to walk to the side of the road near his car so they could conduct sobriety tests ... he lost his balance and rolled down an embankment.
After Unser refused to do sobriety tests ... cops took him to the hospital to have his blood drawn -- and officers say, during their entire interaction with the driver, he was "verbally hostile."
Eventually, Unser was hit with three charges for the incident -- DUI, improper lane change and speeding.
But, a court official tells TMZ Sports, Unser cut a deal with prosecutors this week ... and in exchange for a guilty plea on the DUI charge -- the other 2 counts were dropped.
Unser's punishment for the agreement was a pretty good one for him, considering he was facing up to a year behind bars and a slew of fines and fees.
A court official says Unser got 363 days of probation, 480 hours of community service, and must complete a "victim impact panel" (which generally means Unser will be required to publicly speak about the perils of drunk driving).
Unser also had his driver's license suspended for 365 days from the May 20 arrest ... although the court is allowing him to drive for essential things like work, church, grocery store, etc.
Unser was also required to pay $386.50 in fines and court fees.
Unser's has had several problems with drinking and driving in the past ... he was previously popped for DUI in 2007 and 2011. He was also arrested in 2002 after a booze-fueled altercation with his then-girlfriend.
Unser has spoken publicly about his issues with alcohol and has tried to get help multiple times.
Unser retired from racing back in 2007 after a stellar career which includes an Indy 500 win in 1992 and again in 1994.