“Two men came into Cafe 56” around 8.15 pm local time (1915 GMT) “and fired several rounds of shots,” the public prosecutor said in a statement, without providing information on a possible motive.
“Two customers were killed. Another is in a critical condition.”
The assailants were on the run following the shooting, according to police, who said they had headed in the direction of the railway station after the attack.
“The reason behind the attack is not yet known and will be investigated,” the Basel prosecutor's office said in a statement.
Police have asked anyone with information regarding the incident to come forward.
The road next to the cafe has been cordoned off and traffic redirected.
A bullet hole was visible in one of the windows of the establishment, a small cafe in a residential neighbourhood.
An AFP photographer at the scene saw police dressed in white forensic garb collecting evidence at the site.
“Cafe 56 doesn't have a bad reputation,” a neighbourhood resident told local newspaper Basler Zeitung.
“It was previously an establishment known for its links to the drug world, but since the owner changed several years ago it became an ordinary cafe,” the paper quoted another resident as saying.
A bullet hole in the window of the cafe. Photo: Sebastien Bozon/AFP
Gun crime is infrequent in Switzerland, even though the country has one of the highest rates of firearm ownership in the world.
Citizens are allowed to keep their army-issue weapons at home outside periods of mandatory military service.
This right has been controversial as sometimes weapons are used at home in domestic incidents.
The number of weapons held at home is believed to be two million for a population of eight million, according to Swiss press.
In January, a man clad in military clothing shot and injured two police officers as they searched his home in northeast Switzerland for a suspected cannabis plantation.
The gunman fled but was eventually cornered and after a standoff lasting several hours, which included negotiations over the telephone, he shot himself dead.
Police searching his home found gun publications.