In the book The Two Towers, when Gandalf confronts Saruman after Isengard is destroyed, Gandalf urges Saruman to surrender, more or less, and lists the reasons why he should do so: Isengard is in ruins, your army is gone, your neighbors hate you, and "You have cheated your new master, or tried to do so". The "new master" is clearly Sauron; I'm not sure how Saruman "cheated" him (or tried to cheat him).
The movies are no help in this regard - there, Saruman is fully committed to siding with Sauron from the very beginning. In the books, Saruman initially seems to suggest that he and Gandalf should take the Ring, join forces, and use the power of the Ring against Sauron, but Gandalf is unreceptive to say the least. When the Orcs - some from Isengard, some from Moria, and some from Mordor - kidnap Merry and Pippin, they argue about their orders. The Isengarders are supposed to bring the hobbits to Saruman, the Mordor faction wants to bring them to Barad-Dur, and the Moria faction just wants to kill them and go home. None of the Orcs seem to know about the Ring, which Sauron and Saruman probably hope is being carried by one of the captured hobbits, but they know that the hobbits have something their respective bosses want.
I may have been influenced by having seen the movies before I read the books, but I assumed Saruman's intention was to get the Ring and give it to Sauron in an attempt to curry his favor. But if this was the case, Gandalf's statement makes no sense. Was Saruman only pretending to be Sauron's ally? Was he planning to use the Ring himself, against Sauron and everyone else on Middle-earth? How did he think that would work out?
This seems like a bizarre and idiotic plan, especially from someone known as "the Wise". It is my understanding that Sauron is the same class of being as the Wizards- a Maia - but of a far higher order or subclass than them. I can't imagine that the Ring could be used effectively against Sauron, even by a Wizard. Surely Saruman knows this on some level, or used to know it. Furthermore, if Saruman's plan was to steal the Ring and use it against Sauron, it was profoundly stupid of him to try to steal it in front of Sauron's own Orcs, who would undoubtedly inform their master of what had happened.
Is the scenario I just described - Saruman pretending to be Sauron's buddy, but secretly planning to steal and keep the Ring - what Gandalf meant when he accused Saruman of cheating his new master, or trying to do do? What did Saruman expect would come of this betrayal? What was his end game?