REDWOOD CITY — A South San Francisco man who prosecutors say may have been suicidal when he fired a BB gun at police in July was sentenced Monday in San Mateo County Superior Court to nearly 14 months in county jail.

Raymond Deocareza, 53, had pleaded no contest on March 10 to a felony charge of threatening violence to a police officer. He was given credit on Monday for 270 days already served in jail, leaving him with about four-and-a-half months of remaining time, an official said.

Deocareza behaved strangely and didn’t respond to questions when police officers arrived at his home after a 911 hang-up call from his address on July 21, 2008, according to prosecutors. As he walked toward the officers, he pulled his hands from his pockets, producing what appeared to them to be a handgun, prosecutors said.

Deocareza’s wife ran from the house, screaming to the officers that it was not a real gun, according to police.

When Deocareza appeared to level the gun at officers and begin firing, they released a police dog, who tackled him, prosecutors said. Officers also shocked him with a Taser.

“We can’t say for sure, but it really does seem like he was begging the officers to kill him, and that’s a horrible situation for an officer to be in,” said Chief Deputy District Attorney Steve Wagstaffe.

Deocareza had also faced the misdemeanor charge of brandishing a replica firearm. If he had been convicted of both crimes, he would have faced up to eight years in prison, Wagstaffe said.

On March 10, the second day of his jury trial, Deocareza agreed to a plea offer presented to him by prosecutors.