PARIS -  A French soldier patrolling at the Louvre museum shot and seriously injured a machete-wielding attacker on Friday, thrusting security and the terror threat back into the limelight three months before elections.

Police held hundreds of tourists in secure areas of the renowned tourist attraction after the assailant was shot five times around 10:00 am (0900 GMT) in a public area near one of the museum's entrances.

The knifeman, who yelled "Allahu Akbar" ("God is the Greatest"), is in a serious condition. One soldier received a "minor" head wound and has been taken to hospital, security forces said.

Prime Minister Bernard Cazeneuve said the incident, which will heap more misery on the city's struggling tourism sector, was "terrorist in nature."

It sparked fresh jitters, but also anger, in a country still reeling from a string of terror attacks over the last two years and under a state of emergency since November 2015.  The economy, immigration and security are major issues for voters ahead of presidential and parliamentary elections which has been forecast to confirm the country's shift right after five years of Socialist rule.

US President Donald Trump tweeted that a "new radical terrorist has just attacked in Louvre Museum in Paris. Tourists were locked down. France on edge again. GET SMART US." Witnesses described scenes of panic as shoppers, sightseers and workers fled the Louvre complex following the incident.

"We heard gunshots. We didn't know what it was about. Then we evacuated the employees and we left," a man who works in a nearby restaurant told AFP, asking not to be named.

A woman colleague said: "We saw death coming for us, with everything that's happening at the moment. We were very, very scared."

The Louvre was closed Friday in the wake of the attack, but will re-open on Saturday.

Police raided a building in central Paris as part of the probe into the attack, a source in the inquiry said.

The lucrative Paris tourism industry has been a major casualty of the terror attacks, with visitors cancelling or shortening their stays.

Thousands of troops have been deployed to guard the capital, with groups of soldiers carrying automatic rifles a regular sight inside the Louvre and around its sculpture-filled gardens.

Security forces simulated an attack there in early December to rehearse for such an emergency.

"It's so sad and shocking... we can't let them win, it's horrible," British tourist Gillian Simms, who was visiting Paris with her daughters, told AFP on Friday.

Jessie McCaw, a 18-year-old from the US state of Montana, said she had been evacuated but she appeared unfazed.

"I'm not worried because the police seem prepared in France, which is reassuring," she said.

The huge former royal palace in the heart of the city is home to the Mona Lisa and other legendary artworks as well as shops and restaurants.

City police chief Michel Cadot told reporters that a man whose behaviour was "suspicious" had also been arrested following the attack.

The series of terror attacks in France began in January 2015 when militant gunmen rampaged through the Charlie Hebdo satirical newspaper and a Jewish supermarket, leaving 17 people dead in three days of bloodshed.

Ten months later, gunmen and suicide bombers from the Islamic State militant group attacked bars, restaurants, a concert hall and the national stadium in Paris, killing 130 people.

And last July, a Tunisian extremist rammed a lorry through crowds celebrating Bastille Day in Nice on France's south coast, crushing 86 people to death.

In between, there have been other murders and security scares inspired by the violence of the Islamic State group, sometimes perpetrated by assailants with mental health problems.

Security has been one of the campaign themes ahead of the presidential election in April and May, which is followed by a parliamentary election in June.

Rightwing candidate Francois Fillon has been ensnared in a damaging parliamentary expenses scandal in the last week.

Anti-immigrant far-right leader Marine Le Pen is hoping for a boost from the furore and Trump's election, while 39-year-old centrist independent Emmanuel Macron is also climbing in the polls.

Friday's incident came on the very day that Paris was submitting its formal bid dossier to host the 2024 Summer Olympics.

The Louvre was already suffering from a fall in visitor numbers after the series of attacks in France.

Over the last two years, numbers have fallen by about two million, imperilling its claim to be the most visited museum in the world.

Last year, there was a 15-percent slump in visitors compared to 2015, to around 7.3 million.