Judge Peter Murphy made the ruling at Blackfriars Crown Court in London, where a Muslim woman is due to stand trial on a charge of intimidating a witness, which she denies.
The 22-year-old woman has previously refused to remove her niqab and reveal her face in front of any man. But the order means that if she continues to take the same stand during her trial, she could be jailed for contempt of court.
He said he would offer the woman a screen to shield her from public view but she had to be seen by him, the jury and lawyers.
She would be permitted to keep her face covered while sitting in the dock.
More From This Section
The woman claimed that she has a right to wear the veil under Article 9 of the European Convention on Human Rights. But Murphy argued that the claim amounts to dictating to the court how it should conduct its proceedings.
The issue of veils has sparked a huge debate in Britain over the past few weeks.
Britain's Deputy Prime Minister Nick Clegg courted controversy by saying that it was "inappropriate" for students to wear the full veil in classrooms.
It followed a call by fellow Liberal Democrat minister in the Home Office, Jeremy Browne, for a national debate on whether the niqab should be banned by certain institutions.
"There is a genuine debate about whether girls should feel a compulsion to wear a veil when society deems children to be unable to express personal choices about other areas like buying alcohol, smoking or getting married," he was quoted as saying by the Daily Telegraph.
"The Prime Minister doesn't believe Parliament should legislate on what people do and don't wear on their local high street. Nonetheless, that is not incompatible with institutions having dress codes. Schools are an example. It is for institutions to make this decision," a spokesperson said.