SUNNYVALE — What could have easily become a deadly encounter between a suicidal man with a knife and police officers ended safely after the man was subdued with rubber bullets, according to the Sunnyvale Department of Public Safety.

Police said they kept enough distance from the man to give themselves other options besides their standard firearms. So as the man continued his charge, they opened fire, but with rubber bullets.

The first slowed but did not stop him. A second sent him to the ground, and he was taken into custody and transferred to a psychiatric facility Monday.

“It’s great it ended the way it did,” Capt. Shawn Ahearn said. “That’s not always the case. There’s a lot of factors that influence how things happen. This time it ended in a successful way. We can get the person the help they need, and no one was seriously injured or killed.”

The nonlethal resolution was a respite from a rise in deadly police encounters in the state involving people having mental-health crises. Just last week, San Jose police shot and killed a suicidal man they say pointed a handgun at them after attempts to coax him into surrendering.

Police across California, resigned to the fact that they are more often first responders to these kinds of episodes, are ramping up crisis-intervention training that schools officers in common mental illnesses and de-escalation strategies.

The Monday incident in Sunnyvale began around 12:20 p.m. in the 1000 block of Tasman Drive when a 47-year-old man’s relatives called 911 to report he was suicidal and armed with a large kitchen knife, Ahearn said. The man had just returned home from the hospital and told his family he wanted to die.

Police responded with about eight officers, with at least one having been through crisis-intervention training, Ahearn said. Family members met police outside the mobile home and provided more information about the man, who stayed inside.

“We had the luxury to make sure we could put together a plan” that included using “less lethal” force if possible, Ahearn said. He added officers were also fortunate they had enough distance to use rubber projectiles.

The intervention officer tried to talk the man into disarming and coming out peacefully. In response, the man asked officers to kill him, Ahearn said.

Eventually the man emerged from the house through a back patio area holding a knife. He was about 40 feet away from the officers when he charged at them, police said.

Officers fired a single rubber bullet, which “has some weight and velocity” but did not immediately stop the man. A second rubber bullet was fired, sending the man to the ground. The man dropped the knife when he hit the ground, allowing officers to subdue him with handcuffs.

Ahearn acknowledged that they would have resorted to deadly force if rubber bullets were not effective.

“There’s going to be a point of no return,” Ahearn said. “If he’s too close, he can kill the officer or cause severe injury.”

The man, whose identity was not released by police, was arrested on suspicion of assault with a deadly weapon, displaying a deadly weapon and failure to comply with a police officer, Ahearn said. He was placed on a 72-hour psychiatric hold.

Staff writer Robert Salonga contributed to this report. Contact Mark Gomez at 408-920-5869 and follow him at Twitter.com/MarkMgomez.