Kudakwaske Nheta – who suffers from schizophrenia – admitted breaking a sexual offences prevention order when he followed the nine and six-year-old back to their home in Frimley on June 21.
The order, preventing him from harassing or following children, was imposed after a similar incident earlier in the year.
During his sentencing on Friday (December 17), Guildford Crown Court heard that the 40-year-old was jailed for 15 months five years ago for sexually assaulting a girl under 13 but that his deportation was never enforced.
Nheta, who was supported in court by his mother, will now be held in a psychiatric hospital indefinitely to protect the public from serious harm.
Prosecutor Jill Beale said the children had been playing in the street when Nheta approached them.
“People working nearby saw the defendant hanging around,” she said.
“The children came up and spoke to the workmen as they were distressed by the approach of the defendant.”
Mrs Beale explained that Nheta then followed them home.
“They told their mother and she looked out of the window and saw he was standing outside the house,” she explained.
Defending Nheta, Catherine Atkinson pointed out that the youngsters were with the workmen when they were followed by her client.
“The children were walked home by the three young men who had been in the area,” she said. “They were not on their own.”
After hearing evidence from Dr Jenny Judge on how Nheta suffered from schizophrenia, Judge Moss passed both a hospital and restriction order.
The defendant, of no fixed abode, will not be released until a tribunal decides he is fit to be discharged.
Judge Moss noted that he had not been deported to his homeland despite a recommendation after his conviction in 2005.
He said: “You have been diagnosed as suffering from a serious mental disorder and you have a penchant from harassing and following young victims.
“You have followed two young children from a park and they were so disturbed that they approach some workmen.
“They were so concerned that they walked them home.
“You are not responsible for your actions in many ways as you suffer from mental disabilities.
“It’s to be hoped that given proper care and being on medication you will be in a position to be released into the community with proper checks and balances.”