Tom Forward, who grew up in Malmesbury, will only be freed when the Secretary of State for Justice deems he no longer presents a risk to society.
When the 28-year-old paranoid schizophrenic is finally freed he is likely to be made subject to restrictions on his liberty.
Forward, now of Spinners Croft, Trowbridge, admitted a string of offences against the same woman on May 31 last year.
He pleaded guilty to five counts of rape and one of sexual assault, false imprisonment and assault occasioning actual bodily harm.
A month earlier he was said to have assaulted his father by jabbing a nail into his head after going to the family home in Malmesbury.
As David Forward had not made a formal complaint of assault the case was dismissed due to lack of evidence.
Jane Rowley, defending, told Swindon Crown Court that her client had been held at Fromeside secure unit in Bristol since his arrest a year ago.
Dr Eleanor Hogarth, a consultant psychiatrist from the hospital, gave evidence in support of the hospital orders.
She said one of her colleagues described Forward as 'one of the most unwell patients he had seen in some time,' when he was admitted.
Since being with them she said he had made good and steady progress but said he was still not well.
"It is likely he will need very, very, slow and staggered return to the community," she said.
"We think at the time of the offences he was extremely unwell. Had he been treated these offences would not have occurred," she said.
The court was told Forward had been hearing voices and over the years had been injecting heroin and not taking his anti-psychotic medication.
Rebecca Fairburn, prosecuting, said that in April last year Forward had got a taxi to his father's home in Hobbes Close, Malmesbury.
After dropping him off the cabbie heard a scream and when the police arrived his father was found with a puncture wound to his head caused by a nail.
The court was told that Mr David Forward had not made a statement to the police and there was no witness to what took place.
Judge Robert Pawson dismissed a charge of unlawful wounding but imposed a hospital order with restriction on the matters Forward had admitted.