The Ugandan-born theologian was treated for "locally advanced cancer of the prostate" at a hospital in Leeds on Thursday, his office said in a statement.
The Archbishop said: "I am thankful and grateful for Mr Bill Cross, and his surgical team at St James’ Hospital Leeds, who today operated on me for a locally advanced cancer of the prostate. I am also grateful to the nursing staff who are caring from me.
The Archbishop of York John Sentamu
"I am thankful, too, for all of you who regularly pray for me and support me, especially my staff at Bishopthorpe Palace."
Sentamu said he "will be out of action for some time, and will continue to value your prayers. I look forward to resuming my ministry as soon as possible."
He ended the statement by saying: "As I have often said, during the most trying times, I have derived great comfort from the words of the Taizé chant, ‘Aber du weißt den Weg für mich’, adapted from a passage in Letters and Papers from Dietrich Bonhoeffer, (a German Pastor and Theologian executed by the Nazis in 1945):
“God, gather and turn my thoughts to you. With you there is light, you do not forget me. With you there is hope and patience. I don’t understand your ways, but you know the way for me. I wish you all joy in the Lord."
His office said no further information would be released.
It was not previously known that Sentamu, a widely-touted candidate for the Archbishop of Canterbury, had cancer.
Prostate cancer is the most common cancer in men in the UK, according to Cancer Research UK, and it counts for a quarter of all cancers diagnosed in men.