SAN JOSE — San Jose officials have agreed to pay almost $5 million to settle a lawsuit by a man injured by police gunfire when they found him passed out drunk at a hotel after a costume party and mistook his gold-colored toy gun for the real thing.

The proposed agreement, which the City Council is scheduled to approve Sept. 24, calls for San Jose to pay Javier Gonzales-Guerrero $4,950,000 to settle his federal lawsuit arising from the encounter with police in the early morning of Oct. 23, 2011.

City Attorney Rick Doyle said the settlement was reasonable because the city faced “considerable financial risk if a jury were to side with the plaintiff.”

Gonzales-Guerrero’s lawyers, Joseph Wall and Kenneth Robinson, were not available for comment.

Gonzales-Guerrero, a 25-year-old construction worker at the time, had fallen asleep in a stairwell at the Extended Stay Deluxe Hotel on E. Brokaw Road after attending a Halloween costume party that evening. He had gone there hoping to sleep off the liquor from the party rather than drive home drunk.

Police said cheerleaders staying at the hotel alerted the receptionists to the sleeping and seemingly armed man dressed in green medical scrubs with a hat and a gold-colored revolver tucked in his waistband. Hotel staff couldn’t wake him and phoned police.

At least four officers arrived and shouted commands at Gonzales-Guerrero, who eventually awoke to find himself surrounded by cops aiming their pistols at him.

According to his lawsuit, the officers, identified as Brian Johst, Mark Stephens, Gary Petrakovitz and Tim Stephens, “ignored” his pleas not to shoot and opened fire, riddling his body with more than 20 bullets.

City officials said the officers fired after ordering Gonzales-Guerrero not to touch the gun and then seeing him move his hands toward it. After the shooting, officers stepped on and cracked the handle of the plastic toy gun.

Miraculously, Gonzales-Guerrero, who had no criminal record in the county, survived the barrage after multiple surgeries. The lawsuit said he has a bullet permanently lodged in his spine. He sought compensation for pain and suffering including broken bones, torn muscles and emotional distress. He claimed $2 million in hospital bills, future medical expenses and support services of $3.8 million and a future wage loss of $1.4 million, city officials said.

Gonzales-Guerrero also alleged he was a victim of poor officer training by the city. His lawsuit noted that he was among eight people shot by San Jose police that year, four of whom died, some of the highest totals for the department in years.

But the city’s assistant police chief at the time defended the officers, arguing they cannot assume an apparent firearm is a toy and have just seconds to react to a suspect attempting to shoot his way out of trouble.

The unusual shooting had echoes of a 2000 case in Los Angeles when an officer responded to a Halloween party and shot and killed an actor wearing a gorilla costume and wielding a replica gun that may have been used as a movie or television prop. The officer was cleared.

Contact John Woolfolk at 408-975-9346. Follow him on Twitter at Twitter.com/johnwoolfolk1.