The legal ban on smoking in public places does not apply to state prisons and other Crown premises in England and Wales, the Court of Appeal has ruled.

Three judges allowed a Government appeal against a High Court ruling that the ban covered all public places and all workplaces, including those for which the Crown was responsible.

The judges unanimously agreed that the Crown was not bound by the smoking ban legislation.

Government lawyers had warned the court at a recent hearing that a "particularly vigorous" ban on smoking in state prisons could cause discipline problems and risk the safety of staff and inmates.

The appeal court decision was a defeat for sex offender Paul Black, an inmate at HMP Wymott in Lancashire, who has been serving an indeterminate sentence since 2009 and won the High Court decision in favour of the legal ban.

In reality, smoking is generally not allowed in state-run prisons, except in cells designated for smokers. The ban already applies to private prisons as they are not Crown premises.

Black complained that prison rules were being flouted and needed to be made legally enforceable under Part 1 of the 2006 Health Act, which came into force in July 2007.

His lawyers told the courts that he suffered from a range of health problems due to frequent exposure to second-hand smoke in areas of Wymott, in particular on landings, laundry rooms and healthcare waiting rooms.

Black gave evidence that staff and prisoners were guilty of illicit lighting-up in areas where it was not allowed and not enough was being done to stop them.

His health problems exacerbated by smoke include hypertension and heart disease. A number of other prisoners served statements in support of his claim.

High Court judge Mr Justice Singh ruled in March 2015 that it was "Parliament's intention" that the Health Act should apply in places for which the Crown was responsible and that intention should not be frustrated.

But on Tuesday the appeal judges - Lord Dyson, Master of the Rolls, sitting with Lord Justice McCombe and Lord Justice David Richards - disagreed and set aside the Singh decision.

Sean Humber, head of human rights at law firm Leigh Day, which represented Paul Black, said: "The Court of Appeal's judgment is disappointing as it denies non-smoking prisoners and prison staff the same legal protection from the dangers posed by second-hand smoke as the rest of us.

"It seems absurd to our client that, despite the Health Act specifically identifying controls on smoking in 'prisons', the (Health) Act is to be interpreted as not applying to public sector prisons that make up the vast majority of prisons in England and Wales.

"Given that our client's case was successful in the High Court, we are now discussing an appeal to the Supreme Court with our client."

But the judgment was welcomed by a spokesman for the Prison Service, who said: "The result of this appeal means we are able to roll out smoke-free prisons in a safe and secure way.

"Whilst the Health Act 2006 will not legally bind the Crown properties, including prisons, the smoking ban will be implemented as a matter of policy.

"Our careful approach will ensure staff and prisoners are no longer exposed to second-hand smoke, while not compromising the safety and security of our prisons."

The appeal judges agreed that the "basic, long-established" rule was that no statute bound the Crown unless there was "an express provision" or "a necessary implication" that it was bound.

Mr Justice Singh had found there was an implication that the Crown was bound because the Health Act had been enacted "in furtherance of a move towards a comprehensive ban on smoking" and that statutory purpose would be frustrated if it did not bind the Crown.

Allowing an appeal brought by Justice Secretary Michael Gove, the Master of the Rolls said he did not accept that the Health Act would be "wholly frustrated" if the ban did not apply to the Crown.

The 2004 White Paper on proposals for the ban, while recognising the dangers of both active and passive smoking and the desire for smoke-free environments, had also stated there would be a need for consultation on whether a ban should apply in certain establishments, including prisons, said the judge.

The purpose of the Act could not therefore be said to apply the ban to "all" premises.

The judge said the courts placed considerable weight on the expectation that the Crown "will perform its constitutional duty by acting in the public interest" and meet statutory objectives even if it was under no statutory obligation to do so.

He said it might seem odd at first sight that Parliament should legislate for private prisons, which represented only a small percentage of prisons, to be covered by the ban but not state-run prisons.

But nothing indicated decisively that the Crown was bound by the ban.