Get breaking news alerts and special reports. The news and stories that matter, delivered weekday mornings.

DAMMARTIN-EN-GOELE, France — An intense manhunt for the gunmen who killed 12 people at the offices of a French satirical magazine came to a bloody and dramatic end Friday, when the al Qaeda-linked brothers suspected in the terror attack were killed in a gun battle with police at a printing factory outside of Paris.

In Paris, a second siege played out at a market where a third suspect shot and killed four people before police stormed in and killed him.

In all, 17 people were killed in the terror attacks that began on Wednesday with the massacre at the offices of French satirical magazine Charlie Hebdo, sparking the intense manhunt that paralyzed France and put the West on edge.

French authorities are still searching for a fourth suspect, believed to have aided the supermarket gunman in an attack Thursday that left one police officer dead and another wounded.

The brothers suspected of carrying out the attack on Charlie Hebdo, Cherif and Said Kouachi, were killed by police at a printing facility about 20 miles outside of Paris after a seven-hour hostage siege. Cherif told a French TV station he was "sent by Yemen's Al-Qaeda," and a purported member of the terror group claimed it had directed the attack on the magazine, which had mocked Islam’s Prophet Muhammad.

The U.S. on Friday issued a worldwide travel alert warning that terrorists could target Westerners. French authorities Friday were trying to establish whether any of the attackers had ties to extremist Islamist groups in France or abroad.

The gunman at the grocery store, Amedy Coulibaly, 32, is believed to be connected to the Kouachi brothers, authorities said. French police were hunting for a woman they say was an accomplice, Hayat Boumeddiene. Five people connected to the attackers are still being held by authorities, Paris Prosecutor Francois Molins said.

Explosions and gunfire rang out in both places — at the printing factory in the countryside town of Dammartin-en-Goele and at the kosher market in Paris — in what the French hoped was a conclusion to the spasm of terror that has gripped France for more than two days.

One hostage was freed at the printing factory, authorities said. At the market, four hostages were killed and 15 were freed, according to Israeli government officials who spoke to their French counterparts. The four dead hostages were killed by the gunman before the police raid, Molins said. Four officers were injured, including one who was seriously hurt.

In a speech to the country, President Francois Hollande thanked the security forces for their professionalism. He said that the threat of terrorism was not over, but he said France had overcome its challenge.

Let our news meet your inbox. The news and stories that matters, delivered weekday mornings. This site is protected by recaptcha

"We are free when we are not afraid," he said. "We carry an idea that is bigger than ourselves, and we are able to defend it everywhere where peace is threatened."

He cautioned against racism and called for a national march of unity on Sunday. He described the hostage siege at the kosher market as "a terrible anti-Semitic act."

U.S. officials have said that Said Kouachi, 34, trained with al Qaeda in Yemen several years ago, and his younger brother was convicted on a terrorism charge in 2008. They had been on the run since speeding away from the magazine’s offices after the attack on Wednesday.

The brothers were spotted Friday by police driving in Dammartin-en-Goele, about 20 miles outside the capital, at about 9:30 a.m. local time, or 3:30 a.m. ET. A gunfight broke out, and the brothers apparently holed up in the nearest building they could find, a family-owned printing business, taking a company manager hostage. Said Kouachi was shot in the throat during the gunfight, Molins said.

Yves Albarello, a French lawmaker, was quoted by the French TV station i-Tele as saying that the Kouachi brothers had told police they wanted to “die as martyrs.” The report could not be confirmed by NBC News.

Hours later came word of a second siege at the kosher market. It was not clear how many people were inside, but Thibeaut, the prosecutor’s spokeswoman, suggested there were many because it was the morning before the Jewish Sabbath, which begins Friday night.

Many ambulances were outside the market, and police asked all businesses nearby to close.

The Associated Press, citing an unnamed police official, reported that the gunman had threatened to kill hostages if police stormed the printing plant 25 miles away.

Authorities locked down schools near Dammartin-en-Goele. At one, the Lycee Charles de Gaulle, about 500 students were being kept inside.

“We are all scared,” one student, Angelina Monzili, 16, told NBC News. “We came to school expecting a normal day. We were told that the terrorists are really close. Our families are worried about us. We saw police cars flying past, and ambulances.”

People who live in the area were to told to stay away from windows, turn off lights and stay indoors. “It’s basically a war zone in Dammartin-en-Goele,” one witness told BFM TV.

Nearly 100,000 security personnel were on alert across France as the twin dramas played out.

Paris’ Charles de Gaulle Airport told NBC News that some aircraft coming into land had been redirected to its southern two runways, which are further away from Dammartin-en-Goele. “The town is a little bit too close to the airport,” a spokesman said.

In the tense hours after the Charlie Hebdo attack, profiles began to emerge of the Kouachi brothers, who were known to French and American counterterrorism officials.

Two senior U.S. counterterrorism officials told NBC News that Said Kouachi, 34, traveled to Yemen in 2011 to be trained by al Qaeda in the Arabian Peninsula, which is considered the most violent branch of the terror network.

Cherif Kouachi, 32, was sentenced to prison in 2008 after a Paris court found him and six other men guilty of helping funnel fighters to Iraq. A Homeland Security official told NBC News that the brothers had been on the U.S. no-fly list “for years.”

A purported member of al Qaeda in the Arabian Peninsula claimed in a Twitter message that the group directed the Charlie Hebdo attack, according to Flashpoint Intelligence, a global security firm and an NBC News counterterrorism consultant.

During the siege, Cherif Kouachi spoke by telephone to a French television station, saying he "was sent by Yemen's Al-Qaeda" and had been financed by the group's leader, Anwar al-Awlaki before Awlaki was killed in a U.S. drone strike in 2011.

The final gun battle began after the brothers emerged from the printing factory and started shooting, Molins said. Security forces returned fire, killing them. Their hostage, the company manager, escaped unharmed. It later turned out that a second plant employee had been hiding under a sink, undetected during the entire ordeal.

Investigators found ammunition and heavy weapons in the factory, including a rocket launcher, Molins said.

On Thursday, elite anti-terrorist forces converged on several villages after two masked robbers with machine guns matching the Kouachi brothers' description held up a gas station in Villers-Cotteret, France.

Charlie Hebdo’s offices had been firebombed in the past after publishing cartoons of the Prophet Muhammad. The publication’s chief editor — who was known as Charb — was an outspoken supporter of free speech who had reportedly been put on an al Qaeda hit list. He was among those slain.

NBC News' Alexander Smith, Nikolai Miller, Jason Cumming, Richard Engel, Robert Windrem and Pete Williams, The Associated Press and Reuters contributed to this report. Nancy Ing reported from Paris. Alastair Jamieson reported from London.