The man accused of murdering Tia Sharp killed her after sexually assaulting her, a court heard.
Stuart Hazell, the former boyfriend of Tia's grandmother, allegedly had a sexual attraction for the 12-year-old, jurors at the Old Bailey were told.
Prosecutor Andrew Edis QC said that a sex toy with Tia's blood on it was found at her grandmother's house after she died.
He said: "The prosecution case is that Stuart Hazell had a sexual attraction for Tia Sharp, that there was some form of sexual assault, something of that kind, and that was the reason he killed her."
Mr Edis told the jury that they will have to decide whether Hazell is guilty of murder, or whether Tia died in an accident.
Tia died on the night of August 2/3, but her body was only found on August 10 last year, the court heard, in the loft at her grandmother's house.
Mr Edis said: "The issue in the end for you to decide will be this. Has the evidence made you sure that Tia Sharp was murdered or do you think it may have been an accident?"
The prosecutor went on: "What we know is that after she died he put her in the loft. That's not what you would normally do with someone who has suffered an accident. Generally speaking, if someone has an accident and you are concerned about their health you call an ambulance."
He warned jurors that they will find some of the evidence in the case "distressing".
Hazell, 37, of New Addington, south London is charged with killing the schoolgirl between August 2 and 10 last year. He denies murder.
Her body was found in the loft of her grandmother's house in New Addington, south London a week after she went missing.
Mr Edis told the jury of seven men and five women that the loft had been inspected by police twice before Tia's body was finally found.
"They only found it, I am afraid, because it had started to smell.
"It was quite well hidden. It has been moved up and then across within the loft space."
He said Tia's body had been "carefully wrapped" in a sheet first and then bin bags, then sealed with sellotape.
"As you can imagine, that's not a particularly easy thing to do with a dead human being, but that's what had been done."
The court heard that a total of two memory cards were found in the house, one in the kitchen and one hidden on top of a doorframe.
They contained "extensive pornography", the jury was told, including two "Grade One" images of young under-age girls, and two "extreme images" featuring bestiality.
There were also 11 still images of Tia sleeping, and three video clips of her sleeping in her bedroom.
Another image showed a pre-pubescent girl lying naked on Tia's bed, and there were "professional" pornographic images of young girls performing sex acts, the court heard.
Mr Edis said internet searches on Hazell's phone showed searches of a site that was popular with paedophiles, with searches including the phrases: "naked little girlies", "young, young girlies", and "schoolgirl nudes".
He said Hazell had also visited a pornographic website on August 6 - while Tia's body was in the loft.
Family members were visibly upset by the descriptions, several crying in the public gallery.