What is the world's most resilient and hardy lifeform? The cockroach has a reputation for toughness – many people seem convinced it could even survive a nuclear apocalypse. The tardigrades, or water bears, are probably even hardier. We know for sure that they can survive being blasted into the hostile emptiness of outer space.

Now it is time to meet another contender: a species of algae that thrives in Yellowstone's bubbling hot springs, deep down in the belly of the Earth where the water is as corrosive as battery acid and the environment is laced with arsenic and heavy metals.

The algae's secret? Theft. It stole the genes it needs to survive from other lifeforms. It is a tactic that may be more common than we think.

Most living creatures that live in extreme places are single-celled microbes – bacteria or archaea. These simple and ancient lifeforms lack the more sophisticated biology of animals, but their simplicity is an advantage: it leaves them much better able to cope with extreme conditions.

They have spent billions of years hiding out in the most inhospitable places – deep underground, at the bottom of the ocean, in freezing permafrost or in boiling hot springs. They have taken the long journey, evolving genes over millions or even billions of years that help them cope with almost anything.

But what if other, more complex creatures could just come along and steal those genes? They would effectively take an evolutionary shortcut. In one move they would have the genetics to survive in extreme places. They would get there without putting in the millions of years of evolutionary hard slog it normally takes to evolve those abilities.

This is exactly what the red alga Galdieria sulphuraria has done. It can be found living happily in the hot sulphur springs of Italy, Russia, the US's Yellowstone Park, and Iceland.

Those hot springs have temperatures as high as 56C. Although some bacteria can live in pools at about 100C, and a few can cope with temperatures of about 110C close to deep-sea vents, it is remarkable that a eukaryote – a group of more complex lifeforms that includes animals and plants (red algae is a plant) – can cope with life at 56C.

Most plants and animals could not tolerate those temperatures, and for good reason. Heat causes the chemical bonds within proteins to break, which makes them collapse. This has a catastrophic effect on enzymes, which catalyse the body's chemical reactions. The membranes that encase cells also become leaky, allowing molecules in that would normally be kept out. Once a certain temperature has been reached, the membrane breaks and the cell falls apart.

However, even more impressive is the algae's ability to tolerate acidity. Some of the hot springs have pH values between 0 and 1.

It is positively-charged hydrogen ions, also known as protons, that make something acidic. These charged protons interfere with proteins and enzymes inside cells, messing up the chemical reactions vital for life.

Rather than inheriting its superpowers from its ancestors, the algae stole them from bacteria

That is because proteins are held together by the mutual attraction between positive and negatively charged amino acids. When you introduce a whole new load of positively charged particles you upset the careful balance holding the protein together. The protein can no longer maintain its specific shape and can therefore no longer do its job properly.

"Most other lifeforms can't withstand extreme heat or acidity," says Gerald Schoenknecht, a plant biologist at Oklahoma State University in Stillwater. "Galdieria survives pH 0, which is equivalent to surviving in dilute battery acid. Most other organisms, even bacteria, cannot handle pH values that low."

However, it is not just heat and acidity that Galdieria can tolerate. The alga is resistant to arsenic, mercury and can live in extremely salty environments. The poisonous elements are usually deadly to life, as they inhibit important enzymes involved in respiration. Too much salt, on the other hand, prevents plant cells from taking up water, drying them out and turning them into shrivelled husks.

To find out how Galdieria survives such extreme environments Schoenknecht and fellow scientists from Oklahoma and the Heinrich-Heine University in Germany decoded the alga's genes. What they found surprised them. Rather than inheriting its superpowers from its ancestors, the algae stole them from bacteria.

This gene-swapping phenomenon is known as "horizontal gene transfer". Usually the genes a lifeform carries are ones it inherited from its parents. This is certainly the case in humans – you can trace back your characteristics along the branches of your family tree to the very first humans.

Schoenknecht identified 75 genes in the algae that were taken from bacteria or archaea

However, it turns out that every now and then "alien" genes from a totally different species can incorporate themselves into DNA. The process is very common in bacteria. Some argue it has even happened in humans, although this has been hotly disputed.

When the foreign DNA lands in its new host, it does not necessarily sit there idly. Instead it can set to work hijacking the host's biology, encouraging it to make new proteins. This can give the host species new skills and allow it to survive in new situations. If the gene jumping happens frequently enough, it can send the host organism down a completely new evolutionary path.

In total Schoenknecht identified 75 genes in the algae that were taken from bacteria or archaea. Not all the genes give the algae an obvious evolutionary advantage, and the exact function of many of the genes is unknown.

However, many of the genes do help Galdieria survive in its extreme environment.

Its ability to cope with toxic chemicals like mercury and arsenic is due to genes taken from bacteria.

One of these genes is for an "arsenic pump" which allows the algae to effectively remove arsenic from its cells. Other stolen genes found include those for metal transporters that allow Galdieria to excrete toxic metals, whilst simultaneously taking up essential metals from its environment. Yet other of the purloined genes control enzymes that allow Galdieria to detoxify metals such as mercury.

The algae had also nicked genes that allow it to tolerate high salt levels. Under normal circumstances, a very salty environment will suck the water out of a cell and kill it. But by synthesising compounds inside the cell that equalise the "osmotic pressure", Galdieria escapes that fate.

It is also a mystery – for now – how Galdieria copes with extreme heat

It is thought that Galdieria's ability to tolerate extremely acidic hot springs is because it is impermeable to protons. In other words, it can simply stop acid from entering its cells. It does this by having fewer genes that code for the channels in the cell membrane through which protons normally pass. These channels usually let in positively charged particles like potassium, which are essential to cells – but they can also let in protons.

"It seems that adaptation to the low pH was mainly driven by removing any membrane transport protein from the plasma membrane that would allow protons to enter the cell," says Schoenknecht. "Most eukaryotes have numerous potassium channels in their plasma membrane, Galdieria has only a single gene encoding a potassium channel. So making the plasma membrane 'proton tight' seems to be the main approach to deal with low pH."

However those potassium channels perform important jobs, such as potassium uptake, or maintaining a voltage difference between the cell and outside. How Galdieria stays healthy without the potassium channels is currently entirely unclear.

It is also a mystery – for now – how Galdieria copes with extreme heat. The scientists were unable to identify genes that could explain that particular feature of its biology.

Bacteria and archaea that can live at extremely high temperatures have distinctly different-looking protein and membranes, but the changes that Galdieria has are probably more subtle, says Schoenknecht. "We have some indications that there are changes in membrane lipid metabolism at different growth temperatures, but we do not yet understand what actually happens, and how it relates to adaptation to heat."

It is clear that copying genes has given Galdieria a huge evolutionary advantage. Whilst most of the unicellular red algae related to G. sulphuraria live in volcanic areas and are somewhat heat- and acid-tolerant, few of its relatives can take as much heat, as much acid, as much toxicity, and as much salt as G. sulphuraria can. In fact, in some places the species makes up 80 to 90% of life – a sign of how challenging other species find the conditions G. sulphuraria calls home.

As soon as a resistant gene occurs, it is quickly swapped between different bacteria

There is one obvious question that remains to be answered: just how has Galdieria managed to steal so many genes?

The algae live in an environment that contains lots of bacteria and archaea so in one sense the opportunity to steal genes is there. However, scientists do not know exactly how the DNA has jumped from bacteria to such a different organism. To successfully get into its host, the DNA must first get into the cell, and then into the nucleus – and then it has to splice itself into the host's genome.

"The current best guess is that viruses might have shuttled the genetic material from bacteria and archaea into Galdieria. But this is a speculation, lacking evidence," says Schoenknecht. "Actually getting into the cell might be the hardest step. Once inside the cell getting into the nucleus and getting integrated into the nuclear genome is probably less of a hurdle."

Horizontal gene transfer happens a lot in bacteria. It is why we have such problems with antibiotic resistance, says Schoenknecht. "As soon as a resistant gene occurs, it is quickly swapped between different bacteria."

However, gene swapping was thought to occur far less frequently in more advanced organisms like eukaryotes. It is thought that bacteria have dedicated uptake systems that allow them to take in nucleic acids, and that eukaryotes lack these.

Nevertheless, other examples of advanced creatures stealing genes to survive in extreme places have been found. A species of snow algae, Chloromonas brevispina, which lives in the snow and ice of Antarctica, carries genes that have likely been taken from bacteria, archaea or even fungi.

Jagged crystals of ice can puncture and perforate cell membranes, so creatures living in cold climates must find some way of dealing with this. One way of doing so is to produce ice-binding proteins (IBP) which when secreted from the cell cling to ice, stopping ice crystals from growing.

The beautiful monarch butterfly may even have nicked genes too

James Raymond from the University of Nevada, Las Vegas, mapped the genome of the snow alga and found that the genes for ice-binding proteins were remarkably similar to those seen in bacteria, archaea and fungi, suggesting that they acquired the ability to survive in cold climates from horizontal gene transfer.

"The genes appear to be essential for survival because they have been found in every ice-associated alga examined so far and not in any algae from warmer habitats," says Raymond.

There are a few other examples of horizontal gene transfer in eukaryotes.

Tiny crustaceans that live in Antarctic sea ice seem to have acquired the skill. The critters –Stephos longipes – are able to survive in liquid brine channels in the ice.

"In field measurements I found S. longipes living in supercooled brines within the surface layer of sea ice," says Rainer Kiko, a scientist at the Institute for Polar Ecology at the University of Kiel, Germany. "Supercooled means that the temperature of the liquid is below the freezing point you would expect it to be based on how salty it is."

To survive and stop itself from freezing, S. longipes's blood and all other body liquids contain the same amount of molecules as the surrounding medium, which lowers its freezing point to match that of the water around it. However, the crustacean also produces antifreeze proteins that prevent ice crystals from forming in its blood.

The sea slug can survive using the energy from sunlight

The proteins, which are not found in related crustaceans, are very similar to those found in sea ice algae, suggesting this protein was obtained through horizontal gene transfer.

The beautiful monarch butterfly may even have nicked genes too, this time from a parasitic wasp.

The braconid wasp is famous for injecting an egg along with a virus into a host insect. The viral DNA hijacks the host's brain, turning the host into a zombie, which then acts as an incubator for the wasp egg. Scientists found braconid genes in butterflies, even when they had never been colonised by wasps. The genes are thought to make butterflies more resistant to disease.

It is not just individual genes that eukaryotes have stolen. Sometimes they go in for theft on a grander scale.

A bright green sea slug called Elysia chlorotica is thought to have acquired the ability to photosynthesise through eating algae. The sea slugs swallow chloroplasts – organelles that perform photosynthesis – whole and keep them stored in digestive glands. Then if the going gets tough and there are no more algae to eat, the sea slug can survive using the energy from sunlight to convert carbon dioxide and water into food.

One study suggests the sea slugs have also directly taken genes from the algae. Scientists inserted fluorescent DNA markers into the algal genome, so they could see exactly where the genes were. After feeding on the algae, the sea slug acquired a gene responsible for repairing chloroplasts.

It may be that stealing genes is a fairly common evolutionary tactic

Meanwhile, the cells in our bodies contain tiny energy-generating structures called mitochondria that look distinct from the rest of our cellular structures. Mitochondria even have their own DNA.

A leading theory is that mitochondria existed as independent lifeforms billions of years ago, and that they somehow became incorporated into the cells of the first eukaryotes – perhaps the mitochondria were swallowed but somehow escaped being digested. This event is thought to have happened about 1.5 billion years ago, and was a key milestone in the evolution of all higher life forms such as plants and animals.

It may be that stealing genes is a fairly common evolutionary tactic. After all, it makes sense to let others do all the hard work for you whilst you nip in at the end and reap the rewards. Alternatively, horizontal gene transfer may speed up an evolutionary journey already in progress.

"An organism that is not adapted to heat or acid at all will probably not suddenly inhabit volcanic pools because it acquired the right genes," says Schoenknecht.

"However, evolution is almost always a stepwise process, and with horizontal gene transfer these steps forward might be a bit larger."

Join over five million BBC Earth fans by liking us on Facebook, or follow us on Twitter and Instagram.

If you liked this story, sign up for the weekly bbc.com features newsletter called "If You Only Read 6 Things This Week". A handpicked selection of stories from BBC Future, Earth, Culture, Capital, Travel and Autos, delivered to your inbox every Friday.