The desire to have a selfie as a souvenir from running with the bulls in Spain turned into a near-death experience an American lawyer says he'll never forget.

A charging bull ran over and gored San Francisco resident Jaime Alvarez in the neck during the first run of this year's San Fermin festival in Pamplona, an event immortalized by writer Ernest Hemingway nearly a century ago.

"The joy and the excitement of being in the bullring quickly turned into a scare, into real fear for my life," Alvarez, 46, said Monday at a regional hospital where he was recovering from surgery.

Doctors told Alvarez the bull's horn went deep into his neck and fractured part of a cheekbone. That it didn't hit the jugular vein or major arteries was described to the injured patient as "beyond miraculous."

Alvarez, who works as a public defender in Santa Clara County, California, said he realized how severely he'd been hurt during his encounter with the bull Sunday morning when he touched his neck and his hand came away 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.

Once it appeared certain he would live, the run-in brought rebukes from Alvarez's wife and daughter. The three stopped in Pamplona to check out the famous San Fermin festival while in route to another city where the couple's son was playing in a soccer tournament.

While his daughter and wife cautioned him against joining the crowd that would race the bulls, Alvarez said the energy in the streets of Pamplona on the festival's opening day was too strong to resist.

The running of the bulls — and the nine days of seamless partying that accompanies the festival — draws about 1 million spectators to the city of 200,000 every year. Many foreigners imagine following the footsteps of Hemingway, who channeled his experience in the 1926 novel "The Sun Also Rises."

Hundreds of runners with varying degrees of fitness and hours of sleep race ahead of or next to the bulls charging through a cobblestone and barricaded street course to Pamplona's bullring. Records dating back to 1910 list 16 deaths from the event.

Alvarez says he ran most of the 913-yard (850-meter) course ahead of the bulls. But by the time they entered the bullfighting plaza at the end, the pack of animals had caught up with him.

He said he climbed onto a fence for safety and only returned to the arena to shoot a short video when he thought that the danger had passed. He wanted "a 5-second video scene to say 'Here I am, I did it.'"

That's when the stray bull came at him running fast. The bulls chosen to race in Pamplona often weigh in the range of 500-600 kilos (1,102-1,323 pounds.)

"The impact was unlike anything I've ever felt. It was like being hit by a car or a truck," Alvarez said. "It was scary."

"I was really out of it, really stunned, I didn't know what direction to go," he recalled.

Someone grabbed Alvarez by the arm and pushed through the crowds to get to paramedics, possibly saving the American's life.

His urgent surgery Sunday took 2 ½ hours but Alvarez says his stable condition means he could be discharged as soon as Tuesday. He has promised himself a return to Pamplona to enjoy the festival as a spectator but not a bull racer.

Two other Americans have been injured so far this year. Video footage showed how a bull approached Aaron Froelicher of Florence, Kentucky, from the back, tossed him into the air and gored him in the left thigh. Authorities said the 23-year-old remained hospitalized Monday while recovering from surgery.

Monday's bull run lasting 2 minutes and 23 seconds yielded less serious injuries, despite the fierceness traditionally attributed to bulls from the Cebada Gago ranch, which supplied the second day's pack.

They were surrounded by tame cattle for most of the route, leaving runners scrambling for limited space close to their horns.

Three Spanish runners, including a 19-year-old woman, and a 48-year-old American citizen, were bruised and treated at hospitals.

Another man was stabbed in the back with a bull's horn and treated on the spot, a Red Cross spokesman said.

___

This version has been corrected to show the bulls in Pamplona typically weigh 500-600 kilos and removes reference to specific bull weighing 6 tons.

___

Parra reported from Madrid.

Copyright 2019 The Associated Press. All rights reserved.