EXCLUSIVE

Charles Oakley is learning the hard way ... if you try to cheat a Vegas casino, you'll end up behind bars.

TMZ Sports has learned ... the ex-NBA star was arrested at the Cosmopolitan on July 8 after allegedly trying to pull a fast one during a gambling session -- and it was all caught on video.

Officials from the Nevada Gaming Board tell us Oakley "was suspected of adding to or reducing his wager on a gambling game after the outcome was known."

Unclear what game he was playing at the time -- but one source with knowledge of the incident says Oak tried to pull back a $100 chip after he realized he was going to lose.

FYI, Oakley reportedly made more than $46 mil during his NBA career.

Oak was confronted about the incident -- and it was kicked over to a security team which reviewed the casino video footage ... confirming the alleged cheating.

The 54-year-old was taken into custody at 5:30 PM and booked into Clark County Detention Center.

Oak's gambling charge is serious business -- "to commit or attempt to commit a fraudulent act in a gaming establishment." He faces between 1 to 6 years in prison if convicted.