Prison guards and inmates could face prosecution for flouting smoking ban laws in communal prison areas after a High Court ruling.
The ruling was made after one inmate brought a case complaining about the health impact of second-hand smoke.
The government had argued that as Crown premises, state prisons were exempt from smoke-free legislation.
However, Mr Justice Singh ruled that communal areas in prisons are subject to the laws, which should be enforced.
Exemptions to the Health Act 2006 mean that smoking will still be allowed in cells with the door shut where the smoker is 18 or over.
Paul Black, an inmate at HMP Wymott, argued that he was frequently exposed to second-hand smoke on landings, in laundry rooms and healthcare waiting rooms.
Black also argued that prisoners are legally entitled to anonymous and confidential access to the NHS smoke-free compliance phone line to report infringements of the rules.
Lawyers for the Justice Secretary Chris Grayling maintained that prison rules and regulations, especially the sanction of withdrawal of privileges, were sufficient to deal with incidents of unauthorised smoking.
But Mr Justice Singh, sitting in London, said it was clear that Parliament had intended the act to "apply to all public places and workplaces which fell within its scope, including those for which the Crown is responsible."
The ruling does not take effect until the justice secretary has been given time to lodge an appeal.
The health act already applies to private prisons.
Sean Humber, head of the prison law team at Leigh Day solicitors, said the judgment was important because it confirmed that prisoners were entitled to the same level of protection from the risks posed by second-hand smoke as everyone else.
He added: "The judgment requires the government to reconsider its current refusal to allow prisoners access to a confidential NHS phone line."
by BBC News health correspondent Nick Triggle
Prisons have remained a bit of an anomaly ever since the ban on smoking in public places was introduced in England and Wales in 2007.
It is not allowed in communal spaces, but has been allowed in cells and exercise yards.
Anti-smoking campaigners and the Prison Officers Association have long argued this is wrong.
An estimated 80% of inmates smoke - despite efforts to encourage them to quit.
If this ban does end up being introduced, it should in theory stop that in one swoop. But implementing it would require greater provision of stop-smoking aids, such as nicotine patches, and careful policing to stop cigarettes being smuggled in.
But it's perfectly possible. Other countries such as parts of the US, Canada and New Zealand have already introduced bans.
The Ministry of Justice said it was undertaking measures to lessen the impact of smoking in prisons.
"This includes tightening our current smoking controls, undertaking air quality monitoring in prison accommodation, and maximising the provision of smoking cessation support to those prisoners who want to stop smoking," a spokeswoman said.
"Prisoners can't smoke in communal areas - only in their cells and outside in exercise yards."
She added: "The court has granted permission to appeal the judgement handed down by the High Court that Part 1 of the Health Act binds the Crown. As this is an ongoing legal matter it would not be appropriate to comment further."
The judge acknowledged concerns in the prison service over the impact of his decision that prisoners who feel the need to smoke "may be resistant to the criminalising of that conduct in places where in my view the health act does apply".
BBC home affairs correspondent Danny Shaw said that although Mr Grayling had been given the opportunity to appeal, the government had previously said it would like a ban to be introduced.
"It's simply the practical difficulties of putting it in place which have to be sorted out," he said.
But Ben Gunn, an ex-prisoner and prison campaigner, said a ban would be difficult to implement and could have a destabilising effect.
"Prison is one of the last bastions of smokers. It's a great stress reliever, and prison is a stressful place. On paper this might look like a good idea, but the ramifications will pop up in all sorts of places," he said.
An estimated 80% of the 84,000 inmates at prisons in England and Wales are thought to be smokers.
Last year, a pilot scheme was launched which saw disposable e-cigarettes going on sale in three prisons.