SAN FRANCISCO — The man accused of shooting and killing a 32-year-old woman last week at San Francisco’s Pier 41 admitted to the crime and talked about where he got the gun in an interview with KGO-ABC 7 news.

Francisco Sanchez, 45, was arrested after the July 1 incident and was formally charged with murder Monday. In a 45-minute jailhouse interview, he told the television station that he did shoot Kate Steinle, a former Pleasanton resident who had been living in San Francisco.

Sanchez, however, said he didn’t remember everything that happened, and that he was wandering around Pier 41 after taking some sleeping pills when he found a gun wrapped in a T-shirt. The weapon went off when he picked it up, he told KGO.

Sanchez said he then kicked the gun into the San Francisco Bay and walked off, not knowing he shot someone until he was arrested by police hours later, he told KGO in the interview.

Sanchez said he had been deported to his native Mexico five times. When the station asked Sanchez why he kept coming back to San Francisco, he said he was looking for jobs in restaurant, roofing, landscaping or construction. He also said he knew San Francisco was a sanctuary city where he would not be pursued by immigration officials.

Sanchez said he was sorry and told the station in Spanish that the courts should give him the highest punishment.