In two ferocious, near simultaneous assaults as dusk fell, heavily armed French elite forces shot dead the two gunmen behind Wednesday’s massacre at Charlie Hebdo and a third member of the terror cell wanted for Thursday’s murder of a young policewoman.

But while all the gunmen’s remaining hostages were freed unharmed, with stories emerging of how some hid in cardboard boxes and refrigerators to evade the attackers, the relief was marred by the news that Amedy Coulibaly, suspected of killing police officer Clarissa Jean-Philippe in Montrouge on Thursday, had shot and killed four shoppers in the Jewish supermarket in eastern Paris that he stormed at about 1pm on Friday.

Key members of the French government were due to held a security meeting on Saturday morning to decide on measures to protect against further such attacks. World leaders were telephoning President François Hollande to express their sympathy and support.

At a small printing company in Dammartin-en-Goële, 25 miles north-east of the French capital, police shot dead Chérif and Saïd Kouachi, responsible for the cold-blooded killing of 12 people – including two policemen – at the satirical magazine Charlie Hebdo’s Paris offices.

Facebook Twitter Pinterest Gunfire and explosions at Dammartin-en-Goële siege.

The bloody climax to the unprecedented double hostage-taking brought to an end two days of drama and uncertainty that began on Wednesday morning when the Kouachi brothers burst into the Charlie Hebdo offices.

In the aftermath of the deadliest terror attack on French soil in half a century, BFM TV revealed on Friday night that it had been in telephone contact with Chérif Kouachi from inside the printing factory earlier in the day. In a calm, assured voice, the gunman could be heard telling the station he had been sent “by al-Qaida Yemen”.

On Friday night a member of al-Qaida’s branch in Yemen claimed that the group directed the attack against Charlie Hebdo “as revenge for the honour” of the prophet Muhammad.

Saying it had not released the tapes earlier to avoid compromising the police operations, BFM TV also replayed a conversation it had with Coulibaly in which he said the two attacks against Charlie Hebdo and the Montrouge police officer had been synchronised.

He said he had targeted the Paris shop “because it was Jewish”, that he was holding 16 hostages, and that four people had died when he entered the supermarket. He also claimed to be a member of Islamic State (Isis).

Agence France-Presse said the brothers had come out shooting from the printer’s warehouse where they had been surrounded since early morning. The local MP had earlier told iTele that they had told negotiators they wanted “to die as martyrs”.

Facebook Twitter Pinterest Saïd and Chérif Kouachi. Photograph: Getty Images

Remarkably, a company employee managed to hide from the two gunmen throughout the day under a cardboard box, media reported, escaping unharmed after being able to speak to police on the phone and explain the layout of the warehouse.

But four people, apparently police officers, were injured in the raids, while a fourth, unidentified man – thought to be an accomplice of Coulibaly – also died at the kosher store at the Porte de Vincennes. Citing reliable police and judicial sources, French media reported that police timed their raid on the supermarket as Coulibaly was at prayer: he reportedly used the store’s phone and failed to hang up.

Facebook Twitter Pinterest French police storm supermarket in Port de Vincennes.

At the end of an extraordinary day that swung wildly between the two separate incidents, François Hollande described the past three days’ events as “a tragedy for the nation”. The French president saluted the “courage, flair, and efficacy of the gendarmes, the policemen, everyone who took part. I am proud of them,” and said France “has not finished with these threats. I call for vigilance, unity and mobilisation.”

Earlier, in a highly unusual step, the French president met the far-right Front National leader Marine Le Pen at the Elysée Palace, while France prepared for a “Republican march” on Sunday which David Cameron and his German, Spanish and Italian counterparts, Angela Merkel, Mariano Rajoy and Matteo Renzi, were due to attend.

The Charlie Hebdo bloodbath prompted a global outpouring of outrage, with tens of thousands of people thronging to rallies in support of press freedom under the slogan “jesuischarlie” (“I am Charlie”). Barack Obama was the latest to sign a book of condolence in Washington, inscribing “Vive la France!” while in Paris, thousands had gathered on a day of national mourning and the Eiffel Tower dimmed its lights to honour the dead.

The magazine’s surviving staff, who have moved into the offices of the daily paper Libération, plan a special edition of one million copies on Wednesday.

A wanted notice naming Coulibaly as a suspect in the Montrouge shooting also said police were hunting for a woman, Hayat Boumeddiene, reportedly the gunman’s former girlfriend.

Facebook Twitter Pinterest Amedy Coulibaly, left, and Hayat Boumeddiene. Photograph: Getty Images

It was unclear on Friday night whether or not she was also involved in the supermarket hostage-taking although Paris prosecutor François Molins said that she and Coulibaly had spoken more than 500 times to the Kouachi brothers over the phone.

Questions were being asked about how three men with known jihadi links had been able to carry out the attacks. Chérif Kouachi, 32, was jailed for 18 months for his role in a network sending volunteers to fight alongside al-Qaida in Iraq between 2003 and 2005.

According to L’Obs newsweekly, Coulibaly, 32, who had a list of convictions for theft and drug offences, was “very close” to Chérif.

Both were also investigated in June 2010 on suspicion of being implicated in a plot to break a militant leader out of jail.

At Dammartin, a witness interviewed by France Info radio said he had alerted police after seeing the Kouachi brothers, who were inside the print company, Création Tendance Découverte (CDT), as he arrived at the building.

“My client came to the door,” the witness, Didier, said. “I shook his hand, and the hand of one of the terrorists. They said: ‘It’s the police. Get out.’ ” He had not recognised the men and thought they were police officers, until one said: “We don’t kill civilians, anyway.”

About 1,000 children were evacuated from Dammartin’s schools and local hospitals were placed on alert. Swat teams deployed snipers on roofs and half a dozen helicopters buzzed low over the town.

One resident, Grégory, told BFMTV by telephone: “Everyone here is blocked in their homes. There are four or five helicopters flying overhead and an extraordinary number of police and gendarmes.”

At Porte de Vincennes, the entire area was swamped with police who shut down the main Paris ringroad, as well as schools and shops in the area. Authorities ordered all residents to stay indoors.

The spectacular attacks came as it emerged that the brothers had been on a US terror watch list “for years”.

The head of MI5 said Islamist militants were planning other “mass casualty attacks against the west” and that intelligence services might be powerless to stop them.