PARIS — The French police killed three terrorists on Friday in raids, ending three days of bloodshed that shook a nation struggling with Islamic extremists.

At least 17 French citizens were killed by terrorists in the chaos, officials said, first in a massacre at a satirical newspaper that some Muslims believed insulted the Prophet Muhammad, and then in a roadside shooting on Thursday and two standoffs on Friday that left the gunmen and four of their hostages dead.

The raids, led by heavily armed elite police units, unfolded nearly simultaneously on the eastern edge of Paris and north of the city — at a printing plant where the two brothers of Algerian descent suspected in the newspaper attack held a hostage, and at a kosher supermarket where an armed associate of African origin had lined the place with explosives and threatened to kill the shoppers at his mercy.

In a solemn address to the nation Friday evening, President François Hollande called this week’s violence, the worst spasm of terrorism in France since the 1954-62 Algerian War, the work of “madmen, fanatics” who had created “a tragedy for the nation that we were obliged to confront.”