In the wake of the Dallas sniper attack that killed five police officers, police departments in the Bay Area and beyond are on heightened alert, pairing up officers as a safety measure and revisiting the stark realities of their duties.

The moves come as tensions between law enforcement and communities of color were already ratcheted up after two high-profile killings earlier this week — one in Louisiana and one in Minnesota — but shootings of officers added a new level of tension. The Dallas shooting reportedly came at the hands of Army reservist Micah Johnson.

Johnson, who was black, reportedly said before he was killed by authorities that he was upset about the fatal shootings of Alton Sterling in Baton Rouge, Louisiana, and Philando Castile in Falcon Heights, Minnesota, and wanted to kill white people and white police officers.

San Jose police Chief Eddie Garcia said the risk of serious injury or death is always in the back of the minds of his officers, and that Thursday’s events bring it into focus.

“I can’t imagine not being fearful about what happened in Dallas,” he said. “Our officers are human beings.”

Hours after the Thursday night violence in Dallas, San Jose and Oakland police ordered that patrol units be staffed with two officers. San Francisco police said they already paired officers for night and swing shifts. Similar orders were given out in New York City, Chicago, Boston, Philadelphia and other major cities.

The fear that spurred the pairings was realized in at least two instances: Officers in Georgia and Missouri were shot and wounded Friday in what authorities described as ambush attacks. The Georgia instance involved a man authorities said called 911 to report a break-in, then blindsided the officer who came to investigate. That sparked a shootout in which both the officer and suspect were wounded. Both are expected to survive.

In suburban St. Louis, a motorist shot an officer at least once as the officer walked back to his car during a traffic stop, police said. The officer was hospitalized in critical condition.

San Jose experienced a brief scare Friday morning when someone reported a suspicious package in front of City Hall, a box that sported a sticker with the message “Kill Cops” on it. Police quickly cleared the scene after determining that the box belonged to a contractor and was covering up exposed wiring and that an unknown person put the sticker on it.

It made for tense moments before it was all sorted out, Officer Albert Morales said.

“It raises the hairs on the back of your neck,” he said. “Anytime you get a call about a suspicious package, in light of recent events, we’re all on alert.”

It has also stoked some open resentment. Contra Costa County Sheriff David Livingston, in a staff memo announcing his agency was also going to mandate two-deputy responses to service calls, tacitly criticized President Barack Obama for his incisive public comments after the Minnesota and Louisiana police shootings.

“This is a sad day in our country’s history. Unfortunately we are in an environment where we have little support from our federal executive officials who are quick to criticize the police without knowing all of the facts. As such, we must protect our own,” Livingston wrote.

Police in San Jose have found the slayings of the Dallas officers particularly resonant given that just over two weeks ago, they laid to rest Officer Michael Katherman, who was killed June 14 in a traffic collision while on duty. That came a year after Officer Michael Johnson was slain while responding to a 911 call involving a suicidal man, who fatally shot Johnson in a sniper-style ambush on Senter Road.

Like his counterparts in Los Angeles, which just graduated its latest police academy, Garcia, the San Jose chief, found himself in front of his own stable of cadets Friday to reassure and relay the realities of the life they are entering.

“As officers, we know that it’s a dangerous job. There’s no way around it,” Garcia said. “This fear always exists. All last night did was amplify it.”

Staff writers David DeBolt, Malaika Fraley and Harry Harris and The Associated Press contributed to this report.