Interestingly, I feel that there is another layer to this, and that is Frodo’s mercy (mirroring “the pity of Bilbo” which Gandalf said would prove significant) at play, tangled up in his use of the Ring and the chain of events that would play out.
Frodo is sparing Gollum’s life here, and shaping that into his curse. He is only cursing Gollum—can only curse Gollum—as an effect of this mercy; if Gollum were dead, he could not be cursed by Frodo or the Ring; his survival makes the curse possible and serves as payment for the curse: they are in effect making a bargain here, wherein Golllum’s life and his sentence of dying in the Fires of Doom should he take the Ring again are as one, a package deal, which Gollum “accepts” by retreating with his life.
Then, once Frodo comes to Mount Doom, he cannot cast the ring into the fires; the Ring has him in thrall, since he has used it. Now into the picture again comes Gollum, whose greed for the Ring has surpassed his love of his own life—even having been cursed with death should he touch it again, he craves it and demands it for himself, taking it from Frodo by force.
Thus we see the Ring’s power divided against itself—it has defeated both Frodo and Gollum, and its defeat of Gollum inspires Gollum to fight Frodo for it, invoking the curse. And thus Sauron, who has it, now, by virtue of both its erstwhile Bearers falling under its (and therefore its Lord’s) sway, is cheated out of it by the effects of Frodo’s act of mercy.
Frodo spared Gollum, and used the Ring’s power to set a curse, and when Frodo faltered, it was Gollum whom he spared who took the Ring from him and invoked that curse, falling into the Fires of Doom and, due to the same greed that defeated Frodo, taking the Ring with him.
If there had been no sparing Gollum, there would have been no curse, and Frodo would have had the task Isildur failed at—destroying the (beautiful, useful, lovely ring)—set before him alone, and he may have succeeded, or he may have failed, or he may have tarried too long in the struggle for Sauron’s destruction to come in a timely fashion, or the resolution and the Ring’s destruction may have hurt him far beyond the loss of a finger.
Instead, there was Gollum, in thrall to Sauron yet doomed by Frodo, to take from Frodo both the Ring and the burden of destroying it. Frodo, in his mercy-tinged use of the Ring, effectively shifted the impetus behind the Ring’s destruction from himself to the doom laid on Gollum—and Sauron’s hold over Gollum made it a near certainty that the doom would come to pass: Gollum would die, and not surrender the Ring, and thus the Ring would fall with him into the fires of Mount Doom.
And Frodo … like Indiana Jones in the Chapel of the Holy Grail, could avoid falling himself by either a willingness to let go, or the presence of a loved one to hold him back. Or, y’know, Gollum deciding to bite rather than just grab. A few more options here.