NAIROBI, Kenya — The demonstrators had gathered to protest police violence. They flooded the streets of Nairobi, Kenya, angry over the death of a man in police custody. As two officers approached a man at the protest, he turned to move away. Moments later, one of the officers shot him in the head.

The man, identified by authorities as Boniface Mwangi Kariuki, survived the shooting Tuesday. But the moment, captured in a series of photographs, has inflamed public fury in Kenya over a pattern of police aggression.

Photos of the exchange show an orange muzzle flash on the side of Kariuki’s temple in the instant after the officer fired his gun. Another picture shows Kariuki falling and then slumping to the ground, with the side of his head bleeding.

Tuesday’s demonstration, and the resulting violence, is the latest setback for Kenya’s president, William Ruto.

Next week is the anniversary of deadly demonstrations that convulsed the country, when thousands of people took to the streets to protest a deeply unpopular tax bill, only to be met with a brutal police response in which dozens of people were killed. Hundreds more were injured and at least 30 people were abducted or arbitrarily detained.

Observers said the protests were largely driven by young adults who used social media to organize and raise their concerns directly to their lawmakers. That airing of grievances posed an enormous threat to Ruto, who has been trying to revitalize the country’s ailing economy but has found himself accused of employing authoritarian tactics in cracking down on the protests.

The shocking violence captured in the photographs during Tuesday’s protest comes nearly a year after the anti-tax protests, and reflects the simmering tensions still engulfing Kenya. Police said in a statement Wednesday that Kariuki was recovering from surgery and was in stable condition at Kenyatta National Hospital in Nairobi.