LOS ANGELES — A Colorado man who was wearing a mask and had a knife in his car when he was arrested outside a Beverly Hills home owned by Taylor Swift was released from custody on Tuesday while police continued their investigation.

Julius Sandrock, 38, was arrested Saturday on suspicion of stalking after officers went to the home. Swift, who lives in New York, wasn’t at the home, police said.

Sandrock was freed from jail on Tuesday morning, according to a Los Angeles County Sheriff’s Department website.

It wasn’t immediately clear whether Sandrock had a lawyer.

Meanwhile, police obtained a temporary restraining order preventing Sandrock from possessing guns.

According to the document, Sandrock 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.

Sandrock 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 that he had depression, bipolar disorder, obsessive-compulsive disorder and manic episodes, according to the document.

The arrest 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 misdemeanor and sentenced to three days in jail.