The bill was developed by a commission from a motion proposed by the Swiss People's Party (SVP) and backed by 59 to 54 votes, news agency ATS reported.
The proposal bans anyone from covering their face in public if they threaten public security or religious and social peace.
That could include women wearing the burqa and people covering their faces during demonstrations or protests or for criminal intent.
Despite parliament's support, the ban is not backed by the cantonal government executive, which wants a softer law requiring anyone who does cover their face to reveal it to the authorities if requested.
The motion will be further debated and could go to a referendum.
In a comment piece for the St Gallen Tagblatt newspaper, editor Andri Rostetter slammed parliament's decision, saying such a law would be “not only superfluous but also totally unsuitable”.
There are hardly any women wearing the burqa in eastern Switzerland in any case, he wrote.
“Anyone who speaks of a ‘threat' to social and religious peace is exaggerating,” he said.
Society may be threatened by extremists, fundamentalists and hate preachers “but not by veiled women”.
He also criticized the law's implication that the authorities must make an “instant assessment” as to whether a person who covers their face is a threat.
“When this is the case, nobody knows. Not the police, who must apply the law... Certainly not the cantonal parliament, which has passed the law.”
Last year Ticino became the first Swiss canton to implement a ban on face coverings, including the burqa.
Earlier this year the canton of Glarus refused a similar law, while the federal parliament also rejected a proposal for a nationwide ban.
However the issue is likely to go to a federal referendum since a popular initiative on the subject was last week lodged with the federal authorities after gaining the required number of signatures.
The Egerkingen committee, led by SVP MP Walter Wobmann, launched the campaign in March 2016.
The proposed federal law is along the same lines as Ticino's ban in that it forbids anyone from covering their face in public, apart from certain exceptions for health, safety or weather-related reasons.
The law would also ban anyone from forcing another person to cover their face because of their gender.
Citing a judgement by the European Court of Human Rights, the Egerkingen committee says a “ban on face coverings for religious reasons in public is proportional and does not violate religious freedom or freedom of speech”.
It also targets face coverings worn by vandals and other criminals.