Walter Bennie claimed he was forced to scale down a drainpipe outside his Edinburgh home after his downstairs neighbour attached hi-fi speakers to her ceiling.
Bennie, 69, said he could hear the woman speaking to him through the speakers which forced him from the flat in a bid to escape the noise.
But the OAP ended up in hospital after he lost his grip while descending the drainpipe during the bizarre incident in June last year.
While being treated by medics Bennie voluntarily handed over eight memory cards which were full of depraved images of young children being raped by adults.
Policed then raided two properties in Edinburgh connected to the OAP and seized a number of laptops and hard drives that also had indecent images of children stored on them.
Bennie appeared at Edinburgh Sheriff Court on Friday where he pleaded guilty to a charge of possessing indecent images of children over an 11 year period.
Prosecutor Rosie Cook told the court Bennie was admitted to the capital’s Royal Edinburgh Hospital following “an incident” on June 12 last year.
The fiscal depute said the following day Bennie handed over eight memory cards to a doctor and told him there were “images of children on the memory cards”.
Police were contacted and following a search of two properties several electronic devices were found to have child abuse images stored on them.
The court was told Bennie had collected a massive 36,229 pictures of both male and female children being forced to engage in sexual activity with other children and adults.
Ms Cook said 5198 of the images were rated as Category A – the most depraved end of the spectrum.
Solicitor Andrew Mellor, defending, said his client had “volunteered the [memory] cards to the doctor” but acknowledged “the circumstances are quite unusual in this case”.
Mr Mellor said: “He had been hearing his downstairs neighbour, who he believes, had hi-fi speakers attached to her ceiling and he was hearing her speaking to him.
“He climbed out the window of his flat and tried to get down the drainpipe and fell off, which is why he ended up in hospital.
“There is some suggestion from the hospital that my client was hearing voices but he is adamant that he was hearing his neighbour.”
Sheriff Norman McFadyen placed Bennie on the Sex Offenders Register and deferred full sentence to next month for social work reports and a risk assessment to be prepared.
Bennie pleaded guilty to possessing indecent images of children at his home between December 27, 2009 and September 1 last year.
Don’t miss the latest news from around Scotland and beyond – Sign up to our daily newsletter here .