Mystikal’s getting a taste of freedom … after spending 18 months behind bars on rape charges, he’s finally posted a very hefty bond … TMZ has learned.

Mystikal’s attorneys tell us the rapper was able to scrape together $3 million for the bond … securing his release from a Louisiana prison. We’re told the money came from an advance for a new recording deal, and funds raised by Mystikal’s family and friend.

TMZ broke the story … Mystikal — real name Michael Tyler — was ironing out the final details last month. He’d been behind bars since August 2017 when he was booked for first-degree rape and second-degree kidnapping.