Aldon Smith, the 49ers linebacker, was stabbed during a party at his house last year after he fired a warning shot that he hoped would force guests to leave, a Santa Clara County prosecutor said Wednesday.

The prosecutor, Frank Carrubba, offered new details of what happened at the raucous party east of San Jose as Smith dealt with new troubles.

He was arrested Friday in San Jose on suspicion of drunken driving and marijuana possession. He has reportedly entered a treatment facility and will be away from the team indefinitely.

Smith's alleged attacker at the party, 27-year-old Steven Barba, has been charged with assault, gun possession and gang enhancements in connection with the June 29, 2012, event at Smith's rented home.

More than 100 people showed up, but Smith decided to end it after someone brandished a gun at a bartender, Carrubba said. He said Smith told a group of guests to leave - and was closing his garage door - when someone fired three shots that lodged in the back of the garage.

Smith went to a bedroom, retrieved a .45-caliber handgun and fired a shot into the air, Carrubba said. He reopened the garage door, believing it was safe, but people were still congregating outside.

Carrubba said that as Smith walked out of the garage, someone uttered a "gang slur," prompting Smith to tell the group, "This is my house. I'm Aldon Smith." But the visitors still did not leave, and some told him that they didn't care who he was, Carrubba said.

Barba then used a knife to stab Smith twice, the prosecutor said.

Delanie Walker, a former 49ers tight end who was also at the party, then fired the same .45-caliber handgun into the air, Carrubba said. Another person returned fire, striking two guests, Ronndale Esporlas and Aaron Reyes, who suffered serious injuries.

Esporlas and Reyes are suing Smith and Walker, who now plays for the Tennessee Titans.

A second defendant, 20-year-old Christopher Sanchez of San Jose, had been accused of shooting another party guest, but the charges were dropped. Investigators had wrongly identified Sanchez from a surveillance video, Carrubba said. Smith has not been charged in the case.

Henry K. Lee is a San Francisco Chronicle staff writer. E-mail: hlee@sfchronicle.com Twitter: @henryklee