ENCINITAS, Calif.—Two San Diego County sheriff's deputies were shot and wounded Wednesday by a suspect who was in an hours-long standoff with law officers at his mother's house, authorities said.

The 22-year-old man was distraught by a restraining order obtained by his mother, and more than four hours after the deputies were shot he was still refusing to come out of her house and was threatening to shoot anyone who tried to enter, authorities said.

"Just do exactly as you're told," Sheriff's Capt. Duncan Fraser said at a news conference, adding that he hoped the suspect was watching. "We need to resolve this peacefully and soon."

Both deputies were expected to survive.

They had responded to a call at about 1 p.m. from the mother, who said her son had come to her house and stolen her car.

They didn't find the man but returned at about 3:30 p.m. They learned he had entered the home without his mother's permission and was hiding inside, Fraser said.

The deputies spent several minutes negotiating but the man refused to come out and kept making threats, so they fired tear gas, and the man responded with gunfire, hitting both of them.

Hours later after dark, dozens of law enforcement cars including armored SWAT vehicles jammed the street in Encinitas, a coastal suburb north of San Diego, and nine surrounding houses had been evacuated.

Fraser said the suspect, who was "extremely upset" about a restraining order taken out by his mother last week, was believed to be alone in the home.

One deputy was having surgery for a severe leg injury, the other was treated for a grazing fragment wound to his forehead then released from the hospital.

"He's traumatized, but his training took over and hopefully he'll make a full recovery," Sheriff Bill Gore told UT San Diego after talking to the second deputy.

Noting the shootings of officers and deputies in the manhunt for ex-police officer turned fugitive Christopher Dorner earlier this month, Gore said it has been "a real dark few weeks for all of law enforcement in Southern California."