Michael Houle, 21, was sentenced for possession of a sawed-off shotgun. A jury convicted him of that charge in September but acquitted him of four counts of assault with a deadly weapon.
Houle has 1,662 days' credit for time served and will not serve any prison time, his attorney said.
Sheriff's deputies responded to a report of a man with a gun in a home at 8128 Countryside Drive in Windsor around 1:14 a.m. on June 5, 2008.
The area was not well lit, and as deputies crossed an open area within sight of the home, six shots were fired from the residence, according to the sheriff's office.
No one was injured.
Afterward, deputies found Houle hiding in bushes and arrested him at the scene. Dalton Floyd, 17, Houle's co-defendant, was arrested at another home later that day. Both were charged with attempted murder.
The attempted murder charges were dismissed after a preliminary hearing in 2009, and both men were then charged with four counts of assault with a deadly weapon.
Floyd, now 20, pleaded no contest in August to one charge of assault with a semi-automatic rifle and was sentenced in September to a suspended six-year prison term, three years' probation and one year in Sonoma County Jail. He received credit for time served.
Defense attorney Walter Rubenstein said Houle acted in self-defense because he thought the deputies were men who were coming after him. He believed one of the men was a person he was to testify against in a criminal case, Rubenstein said.
Judge Lawrence Antolini, however, said the state prison sentence is warranted because Houle placed himself and the deputies in danger.
"A sawed-off shotgun is a sawed-off shotgun. I'm happy how it ended but what he did was very wrong. I think justice was done all the way around," Antolini said.
Houle apologized to Antolini for his actions.