Police detained a man who tried to grab the boyfriend of socialite Paris Hilton as the couple arrived at a court to give evidence against a man accused of an attempted break-in at her home.

A photographer and reporters interviewing the couple saw the man appear to get a hand on the neck of Cy Waits before being seized by a bodyguard and taken away.

The incident happened as Hilton and Waits were walking into a Superior Court building in Van Nuys, California, to testify against Nathan Parada, 31, who is charged with attempted first-degree felony burglary.

Hilton later posted on her Twitter account that a "psycho intruder just punched Cy in the back of the head as we were walking into the court house".

James Rainford, 36, was arrested on suspicion of misdemeanour battery on a person in connection with the incident outside court and was being held on £12,000 bail.

Hilton and Waits told the court about being woken by a man banging on a window at her home last August. They left the court without further incident.

Detective Kevin Romine told the court Parada told him and his partner that he had left a halfway house in California several days before going to Hilton's home with the intention of robbing it.

Parada told police he found the Hollywood Hills house after purchasing a map of stars' homes then stayed outside for several hours before going to a back window and pounding on it with the butt of a knife, Det Romine said.

During his interview, Parada told detectives that he planned to steal whatever her could carry, sell it and move to a deserted island, the officer said. He said Parada also told police that he had not taken his antidepressant medication for several days before going to Hilton's home.