Ryan Wilson, 19, sexually abused and battered the primary schoolgirl after joining in a game of hide and seek she was playing with two friends in Cambuslang on 25 May last year.
At the High Court in Glasgow temporary judge Michael O'Grady QC branded Wilson a danger to children and placed him on an order for lifelong restriction, saying he must serve at least six years in prison.
However, Wilson will be kept in jail until he can satisfy parole officers that he is no longer a danger to the public.
Advocate depute Gillian Wade, prosecuting, said that during the attack Wilson threatened to murder the girl and her father if she ever told anyone what he had done.
The court heard that Wilson told his victim's two young friends to start counting while he and the girl hid.
Wilson took the girl on a 15-minute walk to a secluded, wooded area. Once there he repeatedly asked her to show him her pants and when she refused, hit her five times with one of his trainers. He then put his hand over her mouth – restricting her breathing – and told her to "stop f****** greeting".
Ms Wade added: "The accused, by his own admission, says that he punched the girl on the face more than once and that she fell to the ground. He also admitted putting his hands around her throat and sexually assaulting her.
"The assault lasted approximately an hour and once it had finished the accused walked away leaving her alone."
The girl was found in the woods crying, with her clothes covered in dirt, by two young boys who comforted her and walked her back to her home.
The court was told Wilson walked to his grandmother's, where he was laughing and joking. Later when questioned by police Wilson said: "It was a sexual assault and violent."
An examination of the clothes Wilson wore that day revealed the girl's DNA on them.
Wilson admitted attempting to rape the girl and assault. He was originally charged with rape and attempted murder, but the Crown accepted his guilty pleas to reduced charges.
Defence QC Ian Duguid said his client was disgusted by what he had done.
Details of Wilson's horrific crime come after figures showed that a child fell victim to a sexual predator once every six hours in Scotland last year. At least 1,592 sexual offences against children were reported last year, according to figures from Scotland's eight police forces last month.