It's implied that this was a battle of wills, yes. It's useful here to look at how it played out from Frodo's perspective at this time (from The Breaking of the Fellowship):
And suddenly he felt the Eye. There was an eye in the Dark Tower that did not sleep. He knew that it had become aware of his gaze. A fierce eager will was there. It leaped towards him; almost like a finger he felt it, searching for him. Very soon it would nail him down, know just exactly where he was. Amon Lhaw it touched. It glanced upon Tol Brandir - he threw himself from the seat, crouching, covering his head with his grey hood.
He heard himself crying out: Never, never! Or was it: Verily I come, I come to you? He could not tell. Then as a flash from some other point of power there came to his mind another thought: Take it off! Take it off! Fool, take it off! Take off the Ring!
That this event is explicitly linked with Gandalf's statement is confirmed by the following from the chapter The Black Gate is Closed:
Yet even as he spoke his last words to Saruman, and the palantir crashed in fire upon the steps of Orthanc, his thought was ever upon Frodo and Samwise, over the long leagues his mind sought for them in hope and pity.
Maybe Frodo felt it, not knowing it, as he had upon Amon Hen, even though he believed that Gandalf was gone, gone for ever into the shadow in Moria far away...
And so we can say with absolute certainty that the other thought instructing Frodo to take off the Ring was definitely Gandalf's.