Richie Furst used to have a lucrative career on Wall Street; this history prevents him from receiving tuition assistance at Princeton, so he funds his master's degree by referring students to online gambling, for which he receives a cut. After the dean threatens to expel him for these activities, Richie tries to win his tuition using his excellent poker skills in online gambling, but he loses all his money to a cheater, something he is able to prove by statistics.
Richie goes to Costa Rica to confront Ivan Block, who runs the biggest empire of online gambling websites in the world, including the one Richie lost his money on. After Ivan sees the statistics, he finds coders have coded the software to allow them to cheat. After firing those involved, Ivan tells Richie he'll pay him millions per year for him to assist with the site work. Richie slowly begins a romantic relationship with Rebecca Shafran, Ivan's ex-love affair, and Ivan displays no objections to this. FBI agent Shavers kidnaps Richie and threatens to ruin his life in various ways if he does not assist in a conviction of Ivan Block. Shavers cannot do anything legally as he has no authority in Costa Rica, but he takes advantage of this to use tactics that would be illegal/unethical for law enforcement inside the United States. Ivan tells Richie that everyone in the organization ends up confronted by Shavers at some point. Ivan has Richie blackmail a gaming affiliate with videos of his infidelity to force him to sign with Ivan.
Over time, Ivan's organization is revealed to be less than ethical. He sends Richie to bribe Costa Rica gaming director Herrera with too small of a payment, which leads to Richie being beaten. Ivan tells him it comes with the territory of such a wealthy career. Ivan throws Herrera and his bodyguard into a lake of crocodiles, but pulls them out before they are eaten. Richie's friend Andrew Cronin, who works on the software design for Ivan, finds that Ivan is running a Ponzi scheme; the players' accounts have no actual money, and Ivan uses the money as his own bank account, keeping just enough to allow players to cash out when they need to. Cronin disappears and is later found nearly beaten to death. Fearing Richie might be having a change of heart, Ivan buys the massive poker debts of Richie's father and brings him to Costa Rica, using him as a hostage against Richie.
When Richie tries to leave the country, Shavers has drugs planted in his bag and offers to overlook it if Richie agrees to cooperate. A local police officer reveals that the police dislike Ivan but that he would buy his way out of any trouble and destroy whoever tried to take him down. Thanks to Rebecca betraying Ivan, Richie finds out that Ivan has been swindling him all along; Ivan is about to move his operations out of Costa Rica, and from the start he wanted to leave Richie behind as the fall guy. Richie gives out massive bribes to all local officials, including low-level police officers. When the movement day hits, Ivan calls to satirically apologize to Richie, telling him he'll be arrested, as Ivan flies away on a private jet.
When Ivan lands, he finds he has been betrayed: the bribed pilot has instead flown him to Puerto Rico, American territory. Shavers arrests him as Richie and Rebecca fly away on the private jet. Shavers says they're free to go because Richie left a flash drive with him containing sufficient evidence to convict Ivan.