Right as the heist goes off without a hitch and they get the egg, Gabriel (Antonio Banderas) reveals... he is a cop! Everything has been a set up and undercover operation to trap Keith Ripley (Morgan Freeman) in the vault. However, Keith brings up a very good point... if he doesn't get the eggs to Nicky, he will kill Alexandra. Gabriel goes somewhat rogue and steals the eggs himself, leaving Keith locked in the vault while he delivers the eggs to Nicky. He makes it, and they let Alexandra go.
Next, the FBI believes they had caught Nicky. But they have the wrong man - and now there is no case. It turns out that Keith had a back up plan for getting out of the locked vault... and was able to clear the whole place out. Since everything in the vault was stolen and smuggled in from Russia, the company cannot report the items stolen without revealing that they stole them in the first place, and they can't do that, of course.
Once Gabriel tells them that the man they caught and fingered as Nicky isn't Nicky, he is able to identify who Nicky is from a slideshow of known accomplices. He points out the real Nicky... only to find out he isn't Nicky at all. He's actually Victor, a business partner of Keith. Everything is a set up.
Once Gabriel finds out all of this, he gets a phone call from Keith. Alex was in on it too! Also, all of them knew he was a cop before he even came up to New York, and factored that into the plan. They predicted that Gabriel would do what he did, and it all worked. Nobody can prove anything was stolen, nobody can report anything stolen, and nobody but Keith and Victor know where the eggs are.
However, not all is lost. Alex stays in New York, since she did technically nothing illegal, all she did was act like a hostage. She meets Gabriel in the club they met in earlier in the movie, and he asks her if her feelings for him are real. They make out and she says they are, and they go off into the night together.