This article has been updated.

Jaime Alvarez, an attorney for the Santa Clara County Public Defender’s Office, is lucky to be alive after he was gored in the neck while trying to take a selfie video during Spain’s famed running of the bulls over the weekend.

Doctors called it “miraculous” that the San Francisco man escaped a more serious or fatal injury.

Alvarez, 46, told the Associated Press in an interview Monday that he was with his wife and daughter at the San Fermin festival in Pamplona when, against their warnings, he was overtaken by the energy in the streets and decided to take part in the nine-day festival’s opening bull run.

“The joy and the excitement of being in the bullring quickly turned into a scare, into real fear for my life,” Alvarez told the AP.

Alvarez, who has worked as a public defender in the South Bay for two decades, told his colleagues back home that he was “doing well and expects a full recovery,” Assistant Public Defender Damon Silver said to this news organization Monday. Through his office, Alvarez declined further comment beyond his remarks to an AP reporter.

The injured attorney said he had stopped in Pamplona with his wife and daughter while en route to another city where his son was in a soccer tournament.

Alvarez said he had run most of the 850-meter course and had reached Pamplona’s bullring when he climbed onto a fence for safety, and returned to the arena after he presumed that the herd had passed. He said he was trying to record “a 5-second video scene to say ‘Here I am, I did it’ ” when a stray bull made a beeline for him.

“The impact was unlike anything I’ve ever felt. It was like being hit by a car or a truck,” Alvarez said. “I was really out of it, really stunned, I didn’t know what direction to go.”

Soon after, he said he touched his neck and saw his hand covered with blood.

“In the course of a few seconds, a million thoughts came to my mind, and that of dying was definitely one of them,” he said.

Fatefully, Alvarez was grabbed by the arm and pushed through the crowds to get to paramedics, who rushed him to a local hospital, where he underwent a two-and-half-hour surgery to repair the bullhorn injury, which doctors said penetrated deep into his neck and fractured part of a cheekbone, according to the AP.

Alvarez said the doctors who treated him called the fact the horn missed his jugular vein and major arteries “beyond miraculous.” He said he could be discharged as soon as Tuesday.

He was one of five people injured Sunday — including another American, a Kentucky man — during the opening run of the nine-day festival made famous by Ernest Hemingway in his classic novel “The Sun Also Rises.”

Unlike his wife and daughter, who Alvarez said admonished him once they realized he was going to survive, the public defender’s office was more diplomatic about his decision to run with the bulls.

“As an office we encourage our employees to pursue outside interests and explore their passions,” Silver said. “For many it’s traveling, and we think such pursuits are critical to the general wellness of our entire PDO family. We are relieved the incident was not more serious and we are looking forward to Jaime’s return.”

Related Articles S.F. man among three people gored at running of the bulls

Alvarez told the AP that he plans to come back to Pamplona in the future to enjoy the festival, but only as a spectator. In the short term, his office plans to give him some latitude in coming back to work given the circumstances.

“We simply want to make sure he and his family are doing well and ensure he does whatever is best for his health,” Silver said. “He will be missed during his absence, but his full recovery is paramount.”

Associated Press reporters Álvaro Barrientos and Aritz Parra contributed to this report.

Update: July 9, 2019

An earlier version of this story cited an Associated Press report that a 6-ton bull gored Jaime Alvarez. While the weight of the bull could not be immediately confirmed, the typical maximum weight of a bull is just over 1 ton.