Police were fed intelligence about the Charlie Hebdo gunmen's hideout in Dammartin-en-Goele by a graphic designer hiding under a sink.
Lilian Lepere was in the print works when brothers Said and Cherif Kouachi stormed in on Friday morning, taking a hostage as insurance against the heavily armed squadrons of police massing outside.
The 26-year-old remained hidden for the entire siege, which ended when the gunmen burst out of the building with guns blazing before being shot dead by police. The Kouachi brothers never knew he was there.
Mr Lepere, an employee of the printing business, texted police tactical information from his hiding place under a sink in the upstairs canteen for seven hours.
A source told the AFP news agency Mr Lepere was "terrified" but managed to continue his secret communications undetected.
Paris prosecutor Francois Molins told reports that he sent police "tactical elements such as his location inside the premises" as he listened to the gunmen talking.
When the siege started, Mr Lepere sent a text message to his father asking him to get help, the Daily Mail reported.
"I am hidden on the first floor. I think they have killed everyone. Tell the police to intervene," he wrote.
The Kouachi brothers initially took the manager of the store hostage but released him after he helped Said with a neck wound he had sustained in a gunfight with police during the chase earlier in the day.
The building was surrounded by helicopters, police and special forces as nearby schools, businesses and homes were evacuated and the streets cleared for the police assault.
Gunfire and explosions were heard as they moved in at 5pm local time - at the same time as forces stormed a kosher supermarket in Paris where associate Amedy Coulibaly had shot dead four hostages and held at least 10 more for hours.
Officials said the brothers had emerged from the building and opened fire on police before they were killed. Police drove an armoured car into the building to free Mr Lepere, a source told Sky News.
He was taken to police headquarters, where he was quickly reunited with his family feeling "shocked" but "OK", the channel was told.
Mr Lepere was not the only civilian to have a lucky escape from the brothers, who massacred 12 people in cold blood at Charlie Hebdo's offices on Wednesday.
A travelling salesman told France Info radio that he was visiting the print works when the fugitives entered.
"I shook hands with one of them and said hello," the man said. "He replied, 'Monsieur, we don't kill civilians"
The salesman continued: "I am going to buy a lottery ticket. This is the luckiest day of my life."
- The Independent