PARIS -- With explosions and gunfire, security forces on Friday ended a three-day terror spree around Paris, killing the two al-Qaida-linked brothers who staged a murderous rampage at a satirical newspaper, and an associate who seized a kosher supermarket to try to help them escape.

The worst terrorist attacks France has seen in decades killed at least 20 people, including the three gunmen. The fate of a fourth suspect -- the wife of the market attacker -- remained unclear.

Al-Qaida's branch in Yemen said it directed the attack against the publication Charlie Hebdo to avenge the honour of the Prophet Muhammad, a target of the weekly's satire.

Paris shut down a famed Jewish neighbourhood amid fears that a wider cell might launch further violence.

President Francois Hollande called on his nation to remain united and alert.(backslash)

"The threats facing France are not finished," he said. "We must be vigilant," he said -- and defiant. "We are a free people who cave to no pressure."

The drama, which played out on live TV and in social media, began with the brothers Said and Cherif Kouachi methodically killing 12 people Wednesday at the offices of the weekly newspaper Charlie Hebdo before escaping by car. The next day, a gunman police identified as Amedy Couliably shot a policewoman to death south of Paris.

It ended at dusk Friday with near simultaneous raids in two locations: a printing plant in the town of Dammartin-en-Goele, northeast of Paris, where the Koachis were holed up with a lone hostage, and the Paris supermarket where Coulibaly was holding shoppers at gunpoint and threatened to kill them unless police let the Koachis go.

As black-clad security forces surrounded both sites, booming explosions, heavy gunfire and dense smoke heralded the news that the sieges were over and the three gunmen were dead -- but also killed were four of the hostages at the kosher market. Sixteen hostages were freed, one from the printing plant and 15 others from the store.

The attackers had ties to each other and to terrorism that reached back years and extended from Paris to al-Qaida in Yemen. They epitomized Western authorities' greatest fear: Islamic radicals who trained abroad and came home to stage attacks.

After the killings at the Charlie Hebdo offices, Cherif Kouachi, 32, and his 34-year-old brother Said led police on a chase around northeastern France, robbing a gas station and stealing a car before ending up at the printing plant in Dammartin-en-Goele, which is near Charles de Gaulle airport.

BFM television said it spoke with Cherif Kouachi, who told the station they were financed and dispatched by al-Qaida in Yemen.

A member of the al-Qaida in the Arabian Peninsula provided a statement Friday in English to The Associated Press saying the group's leadership "directed the operations and they have chosen their target carefully."

The attack was in line with warnings from the late al-Qaida leader Osama bin Laden to the West about "the consequences of the persistence in the blasphemy against Muslim sanctities," the member said, speaking on condition of anonymity because the group's regulations do not permit him to give his name.

He said the group has delayed its declaration of responsibility for "security reasons."

The brothers were cornered there for much of the day before the explosions and gunfire rang out in the twilight and a police SWAT team clambered onto the roof.

Town spokeswoman Audrey Taupenas said the brothers had died in the clash.

"They said they want to die as martyrs," Yves Albarello, a local lawmaker inside the command post, told French television station i-Tele.

At the kosher grocery near the Porte de Vincennes neighbourhood in Paris, the gunman burst in shooting just a few hours before the Jewish Sabbath began, declaring "You know who I am," the official recounted. The attack came before sundown when the store would have been crowded with shoppers.

Paris police released a photo of Coulibaly and his wife, Hayat Boumeddiene, who the official said was an accomplice.

Several people who were wounded when the gunman opened fire in the grocery store fled and got medical care, the official said.

Minutes before police stormed both sites, Coulibaly had threatened to kill his five hostages if authorities launched an assault on the two brothers, a police official said.

BFM also said it spoke with Coulibaly, who said he and the Kouachis were co-ordinating their actions, and that he was with the militant Islamic State group. The organizations are normally rivals.

The TV station said Coulibaly didn't hang up properly after the phone call and that this allowed police to hear him saying a final prayer before his death, perhaps suggesting that this prompted the police raid.

Police said Coulibaly had been a co-suspect with Cherif Kouachi in a court case involving terrorism that never made it to trial.

The Paris mayor's office shut down all shops along Rosiers Street in the city's famed Marais neighbourhood in the heart of the tourist district. Hours before the Jewish Sabbath, the street is usually crowded with shoppers -- French Jews and tourists alike. The street is also only a kilometre (half a mile) from Charlie Hebdo's offices.

At the kosher grocery near the Porte de Vincennes neighbourhood in Paris, the gunman burst in shooting just a few hours before the Jewish Sabbath began, declaring "You know who I am," the official recounted. The attack came before sundown when the store would have been crowded with shoppers.

Paris police released a photo of Coulibaly and his wife, Hayet Boumddiene, who the official said was his accomplice.

Several people wounded when Coulibaly opened fire in the grocery store were able to flee and get medical care, the official said.

One hundred students were locked down in nearby schools and the highway ringing Paris was closed.

Cherif Kouachi was convicted of terrorism charges in 2008 for ties to a network sending jihadis to fight U.S. forces in Iraq.

A Yemeni security official said his 34-year-old brother, Said Kouachi, is suspected of having fought for al-Qaida in Yemen. Another senior security official said Said was in Yemen until 2012.

Both officials spoke to The Associated Press on condition of anonymity because of an ongoing investigation into Kouachi's stay in Yemen.

Both brothers were also on the U.S. no-fly list, a senior U.S. counterterrorism official said, speaking on condition of anonymity because the official was not authorized to discuss foreign intelligence publicly.

The publication Charlie Hebdo had long drawn threats for its depictions of Islam, although it also satirized other religions and political figures. The weekly paper had caricatured the Prophet Muhammad, and a sketch of Islamic State's leader was the last tweet sent out by the irreverent newspaper, minutes before the attack.

Eight journalists, two police officers, a maintenance worker and a visitor were killed in the newspaper attack, including the paper's editor. Charlie Hebdo plans a special edition next week, produced in the offices of another paper.

Authorities around Europe have warned of the threat posed by the return of Western jihadis trained in warfare. France counts at least 1,200 citizens in the war zone in Syria -- headed there, returned or dead. Both the Islamic State group and al-Qaida have threatened France, home to Western Europe's largest Muslim population.

------

Associated Press writers Samuel Petrequin, Sylvie Corbet, Jamey Keaten, John Leicester and Angela Charlton in Paris; Raphael Satter and Trung Latieule in Dammartin-en-Goele, Jill Lawless in London; Eric Tucker in Washington; Ahmed al-Hag in Sanaa, Yemen; Sarah el-Deeb in Cairo contributed to this report.