Young Thug posted bail for his crew when they were arrested for gun possession at a party last week ... and we're told he's footing the bill for their legal fees too.

Sources close to the rapper tell TMZ ... he ponied up the bail money for all 5 of his homies -- $50k for one guy who allegedly had an AK-47 and $35k each for the remaining 4 -- and they were out of jail about 12 hours after their arrest.

We're told Thug had lawyers waiting for all of them at the jail with a bail bondsman after they were busted at his Dave & Buster's album release/birthday party in Hollywood last week.

HEAVY POLICE PRESENCE
RMG News

Our sources say lawyers' fees are $7k up front for each person ... and YT is handling the ever-rising costs for everyone.

We broke the story ... Young Thug was busted by cops after they allegedly found the rapper and members of his crew in possession of multiple weapons. Law enforcement sources told us a crew member ran into a police cruiser as he was leaving, prompting the vehicle search, which uncovered the weapons.

However, sources close to the rapper say everyone was inside the D&B's and all their cars were parked inside when cops stormed in saying everyone in Thug's crew needed to go outside because they were being arrested.

We're also told 2 of Thug's people had carry permits, but they were still arrested and booked for carrying a concealed weapon in a vehicle ... just like YT and the others.