Thousands of prisoners across the country are turning their jails into some of the most species-rich sites in the country and a newly found interest in conservation is aiding their rehabilitation. The country's 140 prisons include nine internationally recognised sites of special scientific interest (SSSIs) as well as two European special areas for conservation and an internationally important wetland.

Some of the important habitats are on land that is outside the prison walls, but in many cases threatened species such as barn owls, kingfishers, adders and slow-worms also reside at Her Majesty's pleasure within prison grounds.

Dr Phil Thomas, sustainable development manager for the prisons estate, said the organisation is stepping up its work on biodiversity. 'It's really paying dividends, because many SSSIs on our estate are really in good condition,' he said. This is partly to meet the Prison Service's obligations under the 2006 Natural Environment and Rural Communities Act, which requires it to consider the impact of its operations on plant and animal life. But Thomas says the work also benefits the community and makes prisoners less likely to reoffend.

The work, which involves inmates and conservation volunteers, ranges from building bird and bat boxes to surveying bird species from cell windows and constructing purpose-built habitats, such as ponds. The Prime Minister's country residence, Chequers, has also benefited. The estate recently erected a barn owl box made by inmates at Spring Hill prison near Bicester in Oxfordshire.

The country's greenest prison is HMP North Sea Camp, thanks to the huge area of internationally important tidal wetland that surrounds it. The prison authorities manage this land to encourage migrating wading birds such as oystercatchers and curlews and it is recognised under the international Ramsar Convention on Wetlands as internationally important. The thousands of acres of salt marsh outside the prison walls also serve as a deterrent to any would-be escapees. 'It's a natural barrier. Where would you go?' said Thomas.

The Observer was granted exclusive access to two prisons, Spring Hill and Bullingdon, both near Bicester, to see the greening programme in action. Bullingdon, which houses the full range of offenders from thieves to murderers, encourages prisoners to get involved in conservation. Last year inmates made more than 700 bird boxes from scrap wood for the prison grounds and sites managed by the Royal Society for the Protection of Birds. They are now working on an order for 250 more. 'It's amazing what you can do when you've got enough time,' said Richard, a sex offender who is serving a nine-year sentence. 'It's a lot better than doing nothing. We get a very minimal wage, but we are very self-motivated and enjoy what we do,' he added. 'It does pass the time a lot quicker if you are out here busy, rather than sitting brooding in your cell.' Prisoners are paid an average of £9.60 a week.

The thought of prisoners enjoying their work, however beneficial for the environment, runs counter to many people's views of what punishment should be, according to Lyn Costello of Mothers Against Murder and Aggression, a victim support group.

'A lot of the families we deal with want to see them on bread and water and locked up 24 hours a day, but it's not going to work. We mustn't go too far over the line where we start making it a joy for people, but we do live in a supposedly civilised society and we have to think about rehabilitation,' she said. Prison authorities insist that the work helps inmates to recover a sense of self-worth and appreciate that there is a life beyond crime. 'At the end of the day, with everything we are doing in the conservation biodiversity world, if we get one that doesn't reoffend we've succeeded,' said Stuart Jenkins, head of facilities at HMP Bullingdon.

Jenkins said the programme costs virtually nothing because the prisoners mostly use recycled materials. The prisoners and staff also contributed to the RSPB's Big Bird Watch, spotting 25 species inside and outside the walls.

Outside Bullingdon's towering, 8m-high grey concrete walls there is an incongruous sight. The rows of lights trained on the outside of the wall are not mounted on barren land, but on a traditional English meadow that in the summer bristles with wildflowers - including endangered bee orchids. Beyond this is a strip of woodland dotted with tranquil glades that is home to nightingales and muntjac deer.

Here Jenkins has found patches of eggs laid by brown hairstreak butterflies, a threatened species. This season he monitored their breeding success along with conservation volunteers from the Upper Thames Butterfly Group. Rather than numbering the hatchlings, he named them after prisons, such as Scrubs, Wandsworth and San Quentin, the infamous Californian jail.

Although inmates cannot visit the prison's natural haven outside the wall, they do contribute to its upkeep. This year they constructed bee hives to provide pollinators for the wildflower meadow. Jenkins said the honey has proved a big hit with prison officers and visitors, who snap it up for £2 a jar. 'We took 21lb off of one hive. It was gone within an hour,' he said.

Spring Hill is an open prison where prisoners, most of whom are nearing the end of their sentences, have more freedom to move around the grounds. They have dug two ponds to encourage freshwater species such as kingfishers and newts, and they have a pair of barn owls breeding in a specially constructed box mounted on a disused fence post. The land around is managed to encourage barn owl prey, such as voles.

Prize-winning gardens

Leyhill Open Prison in Gloucestershire, situated between the Cotswolds and Vale of Berkeley, has extensive grounds. It has regularly won plaudits at the RHS Chelsea Flower Show, and, when winning gold for its 'Time, The Healer' garden, the prison made headlines and found itself the subject of the 2000 film Greenfingers, starring Clive Owen and Helen Mirren.

Around 75 inmates work on its 55 hectares of farmland and gardens, which include extensive ornamental grounds. There is also a nationally important arboretum run with the Forestry Commission which is often open to the public. Horticulture is run on commercial lines, with salad and vegetables sent to supply other prisons.