Down a track through beech woods so thick you must turn on your car headlights lies a secret meadow, full of flowers. Mauve scabious and darker purple knapweed wave their heads in the aftermath of a summer thunderstorm. "If anyone asks, we're looking at ants and flowers," instructs David Simcox, abruptly swinging his walking boot into the flowery turf. This furtive act of apparent vandalism is one small step in what may be the most complex and successful conservation project in the country: the reintroduction of the once-extinct large blue butterfly.

This insect, which baffled conservationists for more than a century because of its strange and wonderful life cycle, became extinct in Britain in 1979. In the following decade, two scientists brought it back to life: Jeremy Thomas, professor of ecology at Oxford University, worked out exactly what it needed to survive; and Simcox, a conservation consultant for the Centre for Ecology and Hydrology, drove his VW Campervan to an island in Sweden, collected some eggs from the large blues that fly there, and released caterpillars in Devon and Somerset.

The large blue, which is globally endangered, now flies at sites in Somerset in greater numbers than anywhere else in the world. After pioneering that first ever successful reintroduction of a butterfly driven to extinction in Britain, Thomas and Simcox, with assistance from everyone from the National Trust and Gloucestershire Wildlife Trust to Holland & Barrett, are this summer attempting an ambitious second phase. They want to help the large blue move north, to the Cotswolds, where it hasn't flown for 50 years. So far, so straightforward, but establishing a new colony of these unique butterflies is an almost unimaginably delicate and labour-intensive operation.

Simcox's base camp is a stone cottage with rough whitewashed walls close to one of two secret sites where the butterflies are being reintroduced. Every day, he rises at 6am to check on the caterpillars. This time he did not have to drive to Sweden but obtained eggs from a thriving colony on Green Down nature reserve, Somerset, where a record 135,000 eggs were laid this year. Virtually invisible to the naked eye, and smaller than a pinhead, these eggs are attached to thyme. Over several weeks in June and July, Simcox and Thomas, helped by a sharp-eyed conservationist, Sarah Meredith ("not many people can see them. She can," says Simcox), collected flower heads with 400 eggs on them.

Cannibalistic creatures

Simcox then stuck the egg-laden thyme in green foam blocks used by flower arrangers and watered it every day. At first, the caterpillars are virtually invisible and too small to be moved. Simcox only knew they were there by the frass – black pellets of caterpillar poo – that falls from the thyme. After 10 days, he picked up each caterpillar using a fine sable paintbrush and placed it in an individual plastic case, the size of a matchbox. If he didn't, these cannibalistic creatures would start devouring each other.

When the caterpillar sheds its skin for the fourth time, it throws itself off the thyme. At this point, the large blue reveals its full strangeness, which took scientists 100 years fully to understand. In the days when butterflies were collected and pinned up, bringing colour to Victorian drawing rooms, the large blue was the most desirable prize of all. This was not merely for its beauty, or rarity, but because no one could breed it in captivity. Collectors put the caterpillars on thyme only to watch them fall off, shrivel up and die.

During the 20th century, lepidopterists finally discovered the large blue's secret: when the caterpillar hurls itself from the thyme it never eats leaves or flowers again. Instead, it secretes a sweet fluid that attracts ants. They are fooled into thinking the caterpillar is an ant grub and haul it into their underground nests. Here, the caterpillar sings to the deluded ants and feeds voraciously on ant grubs for 10 months of the year, gaining 98% of its body weight this way before pupating. Every June, the butterfly hatches out underground, folds its wings and squeezes up a tunnel and out into the sunshine.

A large blue larva on thyme. Photograph: Butterfly Conservation

This parasitic miracle was understood by the 1950s but the large blue continued to decline. Butterfly collectors were blamed but the reason for its extinction was only discovered by Thomas in the 1970s, just too late to save the species. He worked out that the large blue could perfectly impersonate only one species of red ant, and this ant required particularly hot, well-grazed meadows to survive. The loss of traditional grazing caused its decline – and the large blue's extinction.

It still took Thomas and Simcox more than a decade before their reintroduced populations flourished on land very precisely managed for its needs. They realised they could only establish the butterfly by placing the caterpillars in new sites at the exact moment they dropped off the thyme in search of ants. This has to be in late afternoon, when the ants begin foraging. And if they don't release the ant-ready caterpillars within 24 hours, they die.

Prolonged drought can spell disaster for large blues

And so at 5pm every day, Simcox runs a magnifying glass over hundreds of containers of caterpillars, which are barely 2mm long. "This is very, very laborious," he says, but he still manages to identify caterpillars ready for release with barely a second glance. "People say, 'How do you know that?'" he smiles. "A wasted life, really." Today, he and Meredith pack 44 caterpillars, housed within their tiny boxes, into a margarine tub, and head to the site.

Thunder rumbles overhead. "And God was not happy about the prospects of large blues on the common," quips Simcox. But, actually, it is perfect: the rain encourages the ants to forage, increasing the likelihood they will find a caterpillar. Before the rains came, Simcox sprayed ants' nests with water to induce them to come out. But prolonged drought can still spell disaster for the large blues. During the recent heatwave, Simcox became uncharacteristically gloomy: without rain, the ants stay in their nest and eventually resort to eating their own grubs, including the grub-impersonating large blues.

In the meadow, Simcox scuffs the earth, another ploy to encourage the ants to come out, and Meredith taps a plastic box so that one tiny caterpillar pops out. It is a pale purple colour against the exposed earth, perfectly disguised when eating thyme flowers.

Simcox and Meredith carefully deposit the next caterpillar five metres away. "This is a monster. It's a leviathan of a large blue caterpillar," says Simcox delightedly. It is still just a few millimetres long. If the caterpillars are placed too close together they would be taken into the same nest and end up competing for food. Within seconds, an ant trundles towards the caterpillar, irresistibly lured by its sweet scent. Soon the ant will be "milking" it for this liquid, and will then misguidedly drag it into its nest.

Simcox hopes more than half the caterpillars he has placed here will emerge as adult large blues next June. More than 100 butterflies sounds a lot, but only one third of this population will be flying on any day, and then they still need sunshine to breed and lay eggs. "If we get that, we're away," says Simcox. "Despite all the effort, there are so many things that can go wrong. It might fail the first time. However hard you work, you always need luck as well."

Meadows must be managed correctly

Most difficult of all, he says, is to manage meadows and commons correctly so the ants thrive. The fields need precisely the right amount of grazing. The Cotswolds reintroduction is only possible because Paul Hackman, a land manager for Natural England, has laboured for 10 years to successfully re-establish cattle grazing on the two sites. Many Cotswold sites where the large blue flew in the 1930s are now dense woodland, which is useless for the butterfly.

What is the point of such elaborate reintroductions? As the sun comes out and ghostly pale chalkhill blue butterflies rise from the grass, Simcox pauses. "Isn't this wonderful?" he sighs. Managing meadows for the large blues actually helps dozens of rare species, including orchids and other insects as well as butterflies. If it goes well, this secret site will next year dance with five different species of blue butterfly. It would be pointless, Simcox agrees, if these rare butterflies had nowhere else to go, but this reintroduction is the first step in a landscape-scale project. There are other suitable sites nearby and, with luck, clever land management and the funding to pay for it, this rare butterfly, and other wildlife, will spread naturally, enriching our meadows and animating our summers, without our help at all.

How to spot a large blue butterfly

There are six other blue butterflies in the UK, so if you think you have found a large blue, make sure it has got spots. Unlike the UK's other blue-tinged flutterers, large blues have unique black markings on their upper fore-wings. What's more, they're a different shade of blue to their brighter companions. The large blue has a lighter, steelier tone than, say, the adonis, which has a shinier, sky-blue hue.

Large blues are also notable for their "drunken" flying; other butterflies fly in a more direct fashion. Also, the large blue is not actually that large – it's bigger than the other six, but not by much.

The large blue is only found in very specific locations in Somerset and Devon, including Collard Hill, which is a National Trust nature reserve and open to the public. The butterfly emerges in June and July – so if you see a blue butterfly outside these months and locations, it is another species. Patrick Kingsley

The Butterfly Isles - A Summer in Search of Our Emperors and Admirals by Patrick Barkham is published by Granta in October