The gunman, who police have said is a 29-year-old who was previously known to authorities for criminal activity, is still at large. He was injured in an exchange of gunfire with a soldier, police said, but he has not yet been located.
Christophe Castaner, the French interior minister, said the government had raised the risk level to “urgent attack”, the highest level, and added that border controls had been increased.
French authorities initially said the gunman had killed three people, but a French prosecutor said two people were confirmed dead while the third was brain dead.
France’s counter-terrorism prosecutor has opened an investigation into the incident and security at Christmas markets across the company will be stepped up in the wake of the attack.
In a statement, Mr Castaner said the gunman had opened fire in three places in the city before engaging in firefights with patrolling soldiers.
The gunman then jumped in a taxi and disappeared, according to unconfirmed French media reports.
According to France’s BFM TV, the man had fled his flat in the Neudorf district of the city earlier in the day as it was being searched by police in connection with a robbery.
Thousands of people were confined to buildings as police searched for the gunman. Many have since been released.
Members of the European Parliament, which is based in the city, were sent a message warning of what “seems to be several gun attacks”. They were told to stay in buildings if they were in the city centre.
Police rushed to the scene after shots were heard close to the Christmas market in Place Kleber, one of the central squares in the city, at around 8pm local time (7pm GMT).
He was said to have entered central Strasbourg via the Corbeau bridge to the south of the city centre, before heading to Rue des Orfevres, a popular shopping street close to the cathedral, where he opened fire.
“There were gunshots and people running everywhere,” one shopkeeper told BFM TV. “It lasted about 10 minutes.”
Journalist Bruno Poussard tweeted that there had been a dozen shots fired on his street in the city centre – one or two to begin with, then in bursts.
Roland Ries, the mayor of Strasbourg, said the Christmas market will be closed on Wednesday and flags will be lowered to half-mast.
He tweeted: “A book of condolences will be opened at the Town Hall from today.
“I want to thank the people of Strasbourg and visitors to the city for their patience and understanding.
“A discussion is under way with the education authorities about possible closures to schools on Wednesday.”
The market draws in hundreds of thousands of tourists each year.
The attack came despite tight security, with unauthorised vehicles banned from streets surrounding the market during opening hours and access points to search pedestrians’ bags.
Several MEPs were among those in the city centre when gunshots rang out.
Yorkshire and Humber MEP Richard Corbett was at a restaurant near ”where shots [were] fired”, he tweeted. Hours later, he tweeted that the restaurant had lifted its lock down and he was being allowed to leave while police nearby conducted their mission to get the gunman.
France remains on high alert after a wave of attacks commissioned or inspired by Isis since early 2015, in which about 240 people have been killed. Soon after the shooting in Strasbourg, police indicated that they were beefing up security at the France-Germany border, and the tramway between the two countries was suspended.
President Emmanuel Macron tweeted the “solidarity of the entire nation” is with Strasbourg, the victims and their families.
Additional reporting by agencies