The influence of a Downing Street aide on the appointment of Peter Ball as Bishop of Gloucester was "quite appalling", a former Archbishop of Canterbury has said.
Lord Carey told an inquiry into child sex abuse the extent of the adviser's sway was "deeply disturbing".
He said the appointments commission had favoured another candidate put forward to the prime minister.
He was Bishop of Lewes, in East Sussex, between 1977 and 1992 and Bishop of Gloucester from 1992 until his resignation the following year.
At a trial in October 2015 he admitted a series of offences, committed between the 1970s and 1990s, against 18 teenage boys and young men.
Ball was released from prison in February 2017, having served half his sentence.
The Independent Inquiry into Child Sexual Abuse (IICSA) is focusing this week on how allegations against Ball were dealt with by the Church of England and other authorities.
Lord Carey, who was Archbishop of Canterbury between 1991 and 2002, told the IICSA hearing in London the panel making the recommendation to then Prime Minister John Major had favoured Ball's rival for the job.
Counsel to the inquiry Fiona Scolding QC read a letter from Sir Robin Catford - then Mr Major's appointments secretary - which she described as "a gushing paean to the wonder that is Peter Ball".
Lord Carey told her: "I find this deeply disturbing. The secretary was influencing the mind of the prime minister and going beyond his responsibilities.
"I didn't know this was going on. I find this quite appalling."
Lord Carey said the earliest allegations of Ball's abusive behaviour "came upon us as a great shock", and that they came at the "worst time".
He said a "perfect storm" of events, including the ordination of women and the breakdown of the Prince of Wales's marriage to Diana, Princess of Wales at the end of 1992 into 1993 meant "it was the very worst time to have something like this falling into my lap".
He said: "I couldn't believe that a bishop in the Church of God could do such evil things, so I actually believed him for a time.
"Who was complaining? I didn't know these people. Most of us took a little time to catch on to what this man was doing to younger people."
Lord Carey admitted he had given Ball money to help with legal fees following his arrest and subsequent resignation as Bishop of Gloucester.
But he said there was "nothing improper" about it.
"We felt at the time that as a retired bishop, he needed help," he said.
Ms Scolding questioned Lord Carey about his decision to allow Ball to return to "limited church officiating", after he had resigned in the wake of his police caution for gross indecency.
She said there were a number of letters from Ball and his brother, Michael, within months of his resignation, asking for him to be returned to some form of ministry - actions that Lord Carey's chaplain, Colin Fletcher, said were putting "an intolerable burden" on the then archbishop.
Lord Carey said he had hoped there would be a time when Ball, who was acknowledged within the Church to have talent, would be able to return to the ministry fully.
He said: "I do believe in the possibility of repentance, forgiveness and restitution."
The hearing continues.