The murder on September 1st in the Stockholm suburb Täby was premeditated, the prosecutor said.
"For a long time, he was irritated about noise in the apartment building," prosecutor Ewa Tvengström told the TT news agency.
"And most of all about noise from the apartment above, where the girl lived."
The 31-year-old had bought a hammer, a hacksaw, cleaning equipment and a face mask about two weeks before the attack, she claimed.
"He chose the day by chance. He saw several members of the neighbouring family leave the apartment," Tvengström told TT.
The suspect has confessed to hitting the girl several times in the face and the head.
The man's brother told a friend that the suspect openly said he was going to kill the upstairs family because of the noise.
After the attack, the suspect carried the body down to his apartment before going upstairs again to start cleaning.
As the police arrived on the scene, the man jumped out of the window.
"He was trying to take his own life," Tvengström said.
The man suffers a grave psychological condition, according to a forensic evaluation, which means he cannot be sentenced to prison if found guilty.