The man accused of killing 12-year-old Tia Sharp wrote a letter to his father in prison saying he had made "one mistake" and begging for forgiveness.
Stuart Hazell, 37, is accused of murdering and sexually assaulting the schoolgirl last August and hiding her body in the loft of her grandmother's property. He denies all the charges, claiming Tia died in an accident and he hid her body because he panicked.
During the trial, the jury at the Old Bailey was read out the letter the suspect wrote to his father, Keith, while he was in custody following his arrest.
The letter was intercepted by prison staff. Hazell wrote how his "whole world has collapsed" and he was considering suicide while he awaited trial.
The letter read: "What happened I will explain in time, but put it this way, it was an accident and I panicked.
"Stupid I know but for my stupidity I'm looking at 15 to 18 years. I regret it every second of every day.
"Don't listen to the papers, like everyone else. I will tell you all in time. God I hate myself. I think about ending my life because if I don't someone will, that's definite".
Hazell added: "I should have told police everything. They are trying to say it was sexual. I promise you it wasn't.
"I know Christine [Tia's grandmother] and her family will never forgive me."
He signed off: "May God have mercy on my soul even though I don't deserve it.
"I'm sorry, truly truly sorry xxx."
I'm not like Ian Huntley
The court previously heard how Hazell told prison officers he did not want to be compared to Ian Huntley - the convicted murderer of schoolgirls Holly Wells and Jessica Chapman.
The jury was read a statement from senior prison officer Gerald King in which Hazell said Tia's death was a result of an accident.
The statement read: "He stated that he wanted to end it and take his life. He didn't want to be seen as an Ian Huntley.
"He added that it was an accident, that he had been playing with her at the top of the stairs as they always did.
"She fell down the stairs and broke her neck.
"He wished he could turn back time. He then laid her on the bed for a while, then wrapped her in a blanket and put her in the roof."
Hazell also told a second prison officer: "I'm not like Ian Huntley, it was nothing sexual, I'm not a nonce."
The prosecution allege Hazell killed Tia after he sexually assaulted her at her grandmother's home. The prosecution also accused Hazell of taking a photo of a "dead, naked, pre-pubescent girl" believed to be Tia in her bedroom at her grandmother's home on 3 August - around the time she was reported missing.
Tia's body was not found until 10 August. Police, who had already checked the house twice, discovered a smell emanating from the loft.
The trial continues.