The threat appeared to quickly recede after the assailant was subdued, but it cast a new shadow over the city just as tourism was beginning to rebound after a string of deadly attacks. Coming just hours before Paris finalized its bid for the 2024 Olympics, it also renewed questions about security in the City of Light.
The soldiers' quick action put an end to what French President Francois Hollande said was "no doubt" a terrorist attack at one of Paris' most iconic tourist attractions.
French prosecutor Francois Molins said the assailant was believed to be a 29-year-old Egyptian who had been living in the United Arab Emirates, though his identity has not yet been formally confirmed.
"Everything shows that the assailant was very determined", Molins told a news conference, adding that the attacker, who was shot four times, was in a life-threatening condition in a hospital.
Anti-terrorism prosecutors took charge of the investigation as police carried out raids near the tree-lined Champs-Elysees linked to the attack, which came two months after authorities carried out a special anti-terrorism exercise around the Louvre.
Molins said the attacker was not carrying any identity papers but investigators used his cellphone and a national data base of visa applicants containing their photos and fingerprints to determine that he was a resident of the United Arab Emirates who arrived in Paris on a tourist visa on Jan. 26.
Two days later the suspect bought two military machetes at a gun store in Paris, the prosecutor said. He also paid 1,700 euros for a one-week stay at an apartment in the chic 8th arrondissement of the French capital, near the Champs-Elysees.
In the apartment, police found an Egyptian passport and 965 euros, as well as a residence permit, driver's license and a credit card all issued from the UAE, Molins said. He said the suspect's return flight to Dubai was scheduled for Sunday.
Friday's attack targeted an entrance to a shopping mall that extends beneath the sprawling Louvre, a medieval former royal palace now home to the "Mona Lisa" and hundreds of other masterpieces.
Waving two machetes over his head, the assailant lunged at the soldiers patrolling in the mall, shouting "Allahu Akbar!" or "God is great!" Molins said.
One soldier fought him off and was slightly injured in the scalp. Another soldier fell to the ground as the assailant tried to slash him, then opened fire, shooting the attacker in the stomach. When that didn't stop him, the soldier fired three more time, gravely wounding him. The backpack the man was carrying contained cans of spray paint, but no explosives, Molins said.
The 1,200 people inside the Louvre - one of the world's biggest tourist attractions - were first shuttled into windowless rooms as part of a special security protocol before being evacuated. The museum in central Paris remained closed for the rest of Friday but will reopen on Saturday, Culture Minister Audrey Azoulay told reporters.
Hollande, speaking at a news conference in Malta where he was attending a European Union summit, said that while the Louvre incident was quickly contained, the overall threat to France remains high. He said the incident showed the need for the increased security patrols deployed around France since attacks in 2015.
Those patrols - numbering about 3,500 soldiers in the Paris area - were first deployed following the January 2015 attack on Paris' satirical magazine Charlie Hebdo and reinforced after the November 2015 bomb-and-gun attacks that left 130 people dead at the city's Bataclan concert hall and other sites. The country has been under a state of emergency since.
Interior Minister Bruno Le Roux praised the soldiers involved in Friday's attack, saying "to wear a uniform, as we can see in the propaganda of those who want to attack us, is to be a target."
Restaurant worker Sanae Hadraoui, 32, said she was waiting for breakfast at a McDonald's in the Louvre's restaurant complex when she heard the first gunshot, followed by another and then a couple more.
"I hear a shot. Then a second shot. Then maybe two more. I hear people screaming, 'Evacuate! Evacuate!'" she said. "They told us to evacuate. I told my colleagues at the McDonald's. We went downstairs and then took the emergency exit."
Parisian Makram Chokri, who was shopping in the mall, described hearing a "boom, boom, boom over a few seconds. ... We thought it was an exercise at first but you know, you have a lot of scenarios going through your mind."
Police sealed off mall entrances near the Louvre and closed the area to vehicles, snarling traffic in Paris. Confused tourists were shooed away.
Lance Manus, a tourist from Albany, New York, described young girls crying in panic, and had immediate thoughts of the Sept. 11 attacks in the United States.
"That's what we're used to now," he said. "I mean we have to learn to live with it, be vigilant. So we listen to instructions from the security guards and do what they told us."
Eric Grau, a high school teacher chaperoning a group of 52 students, said: "We were in one of the galleries and a voice came through the loudspeakers to alert us, saying there was an alert." He said the group was taken to safety in the African art gallery.
The attack came hours before the city unveiled its bid for the 2024 Olympics. Paris is competing against Budapest and Los Angeles for the games, which it hasn't hosted since 1924.
Speaking outside the Louvre, Paris Mayor Anne Hidalgo said terrorism threatens all of the world's big cities and "there is not a single one escaping that menace."
The speed with which Paris largely went back to normal after the attack, with officers gradually dismantling barricades and pulling down police tape around the Louvre just three hours later, underscored how the French city has - unwillingly but stoically - been forced to learn to live with extremist threats.
Within hours, French radio stations went back to talking about storms battering the west coast and school holiday traffic.
Associated Press writers Angela Charlton, Greg Keller, Samuel Petrequin, Alex Turnbull and Jeff Schaeffer in Paris contributed to this report.
Copyright 2018 The Associated Press. All rights reserved. This material may not be published, broadcast, rewritten or redistributed.