A man arrested outside a Beverly Hills home owned by Taylor Swift was wearing a mask and had a knife in his car when he was held, police have said.

Julius Sandrock, 38, was arrested on Saturday on suspicion of stalking after officers went to the home.

Swift, who lives in New York, was not at the property, officers said.

Sandrock was released from custody on Tuesday while police continued their investigation, according to Los Angeles County Sheriff’s Department.

Officers obtained a temporary restraining order preventing Sandrock from possessing guns.

According to the document, he was wearing a mask and rubber gloves when he was taken into custody and told police he had driven from his home in Broomfield, Colorado, to see Swift.

He told officers he owned three handguns and was on probation in Colorado for firing one, police said.

A search of his car turned up a knife, rope, ammunition and more masks and gloves, according to the restraining order.

Prescription medications, including oxycodone, were also found and Sandrock told arresting officers he had depression, bipolar disorder, obsessive-compulsive disorder and manic episodes, according to the document.

The incident followed the April 8 arrest of a homeless man on suspicion of trespassing after he tried to climb a wall at the same property and ignored warnings by security guards to leave.

Swift was not at the home.

Justin Lilly, 23, was charged with a misdemeanour and sentenced to three days in jail.