When you were born, you inherited half your genes from your mother and half from your father. That’s your lot. Those inherited bits of DNA will remain with you for all of your life, with no further additions or omissions. You can’t have any of my genes, and I can’t acquire any of yours.

But imagine a different world where friends and colleagues can swap genes at will. If your boss has a gene that makes her resistant to various viruses, you can borrow it. If your child has a gene that puts him at risk of disease, you can swap it out for your healthier version. If distant relatives have a gene that allows them to better digest certain foods, it’s yours. In this world, genes aren’t just heirlooms to be passed on vertically from one generation to the next, but commodities to be traded horizontally, from one individual to another.

This is exactly the world that bacteria live in. They can exchange DNA as easily as we might exchange phone numbers, money or ideas. Sometimes, they sidle up to one another, create a physical link, and shuttle bits of DNA across: their equivalent of sex. They can also scrounge up discarded bits of DNA in their environment, left by their dead and decaying neighbors. They can even rely on viruses to move genes from one cell to another. DNA flows so freely between them that the genome of a typical bacterium is marbled with genes that arrived from its peers. Even closely related strains might have substantial genetic differences.

Bacteria have been carrying out these horizontal gene transfers, or HGT for short, for billions of years. But it wasn’t until the 1920s that scientists first realized what was happening. They noticed that harmless strains of Pneumococcus could suddenly start causing disease after mingling with the dead and pulped remains of infectious strains. Something in the extracts had changed them. In 1943, a “quiet revolutionary” and microbiologist named Oswald Avery showed that this transformative material was DNA, which the non-infectious strains had absorbed and integrated into their own genomes. Four years later, a young geneticist named Joshua Lederberg (who would later popularize the word “microbiome”) showed that bacteria can trade DNA more directly.

Sixty years on, we know that HGT is one of the most profound aspects of bacterial life. It allows bacteria to evolve at blistering speeds. When they face new challenges, they don’t have to wait for the right mutations to slowly amass within their existing DNA. They can just borrow adaptations wholesale, by picking up genes from bystanders that have already adapted to the challenges at hand. These genes often include dining sets for breaking down untapped sources of energy, shields that protect against antibiotics or arsenals for infecting new hosts. If an innovative bacterium evolves one of these genetic tools, its neighbors can quickly obtain the same traits. This process can instantly change microbes from harmless gut residents into disease-causing monsters, from peaceful Jekylls into sinister Hydes.

They can also transform vulnerable pathogens that are easy to kill into nightmarish “superbugs” that shrug off even our most potent medicines. The spread of these antibiotic-resistant bacteria is undoubtedly one of the greatest public health threats of the 21st century, and it is testament to the unbridled power of HGT.

Animals aren’t so fast. We adapt to new challenges in the usual slow and steady way. Individuals with mutations that leave them best suited to life’s challenges are more likely to survive and pass on their genetic gifts to the next generation. Over time, useful mutations become more common, while harmful ones fade away. This is classic natural selection—a slow and steady process that affects populations, not individuals. Hornets hawks, and humans might gradually accumulate beneficial mutations, but that individual hornet, or this specific hawk, or those particular humans can’t pick up beneficial genes for themselves.

Except sometimes, they can. They could swap their symbiotic microbes, instantly acquiring a new package of microbial genes. They can bring new bacteria into contact with those in their bodies, so that foreign genes migrate into their microbiome, imbuing their native microbes with new abilities. On rare but dramatic occasions, they can integrate microbial genes into their own genomes.

Excitable journalists sometimes like to claim that HGT challenges Darwin’s view of evolution, by allowing organisms to escape the tyranny of vertical inheritance. (“Darwin was wrong,” proclaimed an infamous New Scientist cover—wrongly.) This is not true. HGT adds new variation into an animal’s genome but once these jumping genes arrive in their new homes, they are still subject to good ol’ natural selection.

Detrimental ones die along with their new hosts, while beneficial ones are passed on to the next generation. This is as classically Darwinian as it gets—vanilla in its flavor and exceptional only in its speed. By partnering with microbes, we can quicken the slow, deliberate adagio of our evolutionary music to the brisk, lively allegro of theirs.

**********

Along the coasts of Japan, a reddish-brown seaweed clings to tide-swept rocks. This is Porphyra, better known as nori, and it has filled Japanese stomachs for over 1,300 years. At first, people ground it into an edible paste. Later, they flattened it into sheets, which they wrapped around morsels of sushi. This practice continues today and nori’s popularity has spread all over the world. Still, it has a special tie to Japan. The country’s long legacy of nori consumption has left its people especially well equipped to digest the sea vegetable. We don’t have any enzymes that can break down the algae, and neither do most of the bacteria in our guts.

But the sea is full of better-equipped microbes. One of these, a bacterium called Zobellia galactanivorans, was discovered just a decade ago, but has been eating seaweed for much longer. Picture Zobellia, centuries ago, living in coastal Japanese waters, sitting on a piece of seaweed and digesting it. Suddenly, its world is uprooted. A fisherman collects the seaweed and uses it to make nori paste. His family wolfs down these morsels, and in doing so, they swallow Zobellia. The bacterium finds itself in a new environment. Cool salt water has been substituted for gastric juices. Its usual coterie of marine microbes has been replaced by weird and unfamiliar species. And as it mingles with these exotic strangers, it does what bacteria typically do when they meet up: It shares its genes.

We know that this happened because Jan-Hendrick Hehemann discovered one of Zobellia’s genes in a human gut bacterium called Bacteroides plebeius. The discovery was a total shock: what on earth was a marine gene doing in the gut of a landlubbing human? The answer involves HGT. Zobellia isn’t adapted to life in the gut, so when it rode in on morsels of nori, it didn’t stick around. But during its brief tenure, it could easily have donated some of its genes to B. plebeius, including those that build seaweed-digesting enzymes called porphyranases.

Suddenly, that gut microbe gained the ability to break down the unique carbohydrates found in nori, and could feast on this exclusive source of energy that its peers couldn’t use. Hehemann found that it is full of genes whose closest counterparts exist in marine microbes rather than in other gut-based species. By repeatedly borrowing genes from sea microbes, it has become adept at digesting sea vegetables.

B. plebeius isn’t alone in thieving marine enzymes. The Japanese have been eating nori for so long that their gut microbes are peppered with digestive genes from oceanic species. It’s unlikely that such transfers are still going on, though: Modern chefs roast and cook nori, incinerating any hitchhiking microbes. The diners of centuries past only managed to import such microbes into their guts by eating the stuff raw.

They then passed their gut microbes, now loaded up with seaweed-busting porphyranase genes, to their children. Hehemann saw signs of the same inheritance going on today. One of the people he studied was an unweaned baby girl, who had never eaten a mouthful of sushi in her life. And yet, her gut bacteria had a porphyranase gene, just as her mother’s did. Her microbes came pre-adapted for devouring nori.

Hehemann published his discovery in 2010 and it remains one of the most striking microbiome stories around. Just by eating seaweed, the Japanese diners of centuries past booked a group of digestive genes on an incredible voyage from sea to land. The genes moved horizontally from marine microbes to gut ones, and then vertically from one gut to another. Their travels may have gone even further. At first, Hehemann could only find the genes for porphyranases in Japanese microbiomes and not North American ones. That has now changed: Some Americans clearly have the genes, even those who aren’t of Asian ancestry.

How did that happen? Did B. plebeius jump from Japanese guts into American ones? Did the genes come from other marine microbes stowing away aboard different foods? The Welsh and Irish have long used Porphyra seaweed to make a dish called laver; could they have acquired porphyranases that they then carried across the Atlantic? For now, no one knows. But the pattern “suggests that once these genes hit the initial host, wherever that happens, they can disperse between individuals,” says Hehemann.

This is a glorious example of the adaptive speed that HGT confers. Humans don’t need to evolve a gene that can break down the carbohydrates in seaweed; if we swallow enough microbes that can digest these substances there’s every chance that our own bacteria will “learn” the trick through HGT.

HGT depends on proximity, and our bodies engineer proximity on a huge scale by gathering microbes into dense crowds. It is said that cities are hubs of innovation because they concentrate people in the same place, allowing ideas and information to flow more freely. In the same way, animal bodies are hubs of genetic innovation, because they allow DNA to flow more freely between huddled masses of microbes. Close your eyes, and picture skeins of genes threading their way around your body, passed from one microbe to another. We are bustling marketplaces, where bacterial traders exchange their genetic wares.

***********

Animal bodies are home to so many microbes that occasionally, their genes make their way into our genomes. And sometimes, these genes bestow their new hosts with incredible abilities.

The coffee berry borer beetle is a pest that has incorporated a bacterial gene into its own genome, which allows its larvae to digest the lush banquets of carbohydrates within coffee beans. No other insect—not even very close relatives—has the same gene or anything like it; only bacteria do. By jumping into an ancient coffee borer, the gene allowed this unassuming beetle to spread across coffee-growing regions around the world and become a royal pain in the espresso.

Farmers, then, have reasons to loathe HGT—but also reasons to celebrate it. For one group of wasps, the braconids, transferred genes have enabled a bizarre form of pest control. The females of these wasps lay their eggs in still-living caterpillars, which their young then devour alive. To give the grubs a hand, the females also inject the caterpillars with viruses, which suppress their immune systems. These are called bracoviruses, and they aren’t just allies of the wasps: They are part of the wasps. Their genes have become completely integrated into the braconid genome, and are under its control.

The bracoviruses are domesticated viruses! They’re entirely dependent on the wasps for their reproduction. Some might say they’re not true viruses are all; they’re almost like secretions of the wasp’s body rather than entities in their own right. They must have descended from an ancient virus, whose genes wheedled their way into the DNA of an ancestral braconid and stayed there. This merger gave rise to over 20,000 species of braconid wasps, all of which have bracoviruses in their genomes—an immense dynasty of parasites that uses symbiotic viruses as biological weapons.

Other animals have used horizontally transferred genes to defend themselves from parasites. Bacteria, after all, are the ultimate source of antibiotics. They have been at war with each other for billions of years and have invented an extensive arsenal of genetic weapons for beating their rivals. One family of genes, known as tae, make proteins that punch holes in the outer walls of bacteria, causing fatal leaks. These were developed by microbes for use against other microbes. But these genes have found their way into animals, too. Scorpions, mites and ticks have them. So do sea anemones, oysters, water fleas, limpets, sea slugs and even the lancelet—a very close relative of backboned animals like ourselves.

The tae family exemplifies the kind of genes that spread very easily through HGT. They are self-sufficient, and don’t need a supporting cast of other genes to do their job. They are also universally useful, because they make antibiotics. Every living thing has to contend with bacteria, so any gene that allows its owner to control bacteria more effectively will find gainful employment throughout the tree of life. If it can make the jump, it’s got a good chance of establishing itself as a productive part of its new host. These jumps are all the more impressive because we humans, with all our intelligence and technology, positively struggle to create new antibiotics. So flummoxed are we that we haven’t discovered any new types for decades. But simple animals like ticks and sea anemones can make their own, instantly achieving what we need many rounds of research and development to do—all through horizontal gene transfer.

These stories portray HGT as an additive force, which infuses both microbes and animals with wondrous new powers. But it can also be subtractive. The same process that bestows useful microbial abilities upon animal recipients can make the microbes themselves wither and decay, to the point where they disappear entirely and only their genetic legacies remain.

The creature that best exemplifies this phenomenon can be found in greenhouses and fields around the world, much to the chagrin of farmers and gardeners. It’s the citrus mealybug: a small sap-sucking insect that looks like a walking dandruff flake or a woodlouse that’s been dusted in flour. Paul Buchner, that super-industrious scholar of symbionts, paid a visit to the mealybug clan on his tour of the insect world. To no one’s surprise, he found bacteria inside their cells. But, more unusually, he also described ‘‘roundish or longish mucilaginous globules in which the symbionts are thickly embedded”. These globules languished in obscurity for decades until 2001, when scientists learned that they weren’t just houses for bacteria. They were bacteria themselves.

The citrus mealybug is a living matryoshka doll. It has bacteria living inside its cells, and those bacteria have more bacteria living inside them. Bugs within bugs within bugs. The bigger one is now called Tremblaya after Ermenegildo Tremblay, an Italian entomologist who studied under Buchner. The smaller one is called Moranella after aphid-wrangler Nancy Moran. (“It is a kind of a pathetic little thing to be named after you,” she told me with a grin.)

John McCutcheon has worked out the origins of this weird hierarchy—and it’s almost unbelievable in its twists and turns. It begins with Tremblaya, the first of the two bacteria to colonize mealybugs. It became a permanent resident and, like many insect symbionts, it lost genes that were important for a free-living existence. In the cozy confines of its new host, it could afford to get by with a more streamlined genome. When Moranella joined this two-way symbiosis, Tremblaya could afford to lose even more genes, in the surety that the new arrival would pick up the slack. Here, HGT is more about evacuating bacterial genes from a capsizing ship. It preserves genes that would otherwise be lost to the inevitable decay that afflicts symbiont genomes.

For example, all three partners cooperate to make nutrients. To create the amino acid phenylalanine, they need nine enzymes. Tremblaya can build 1, 2, 5, 6, 7, and 8; Moranella can make 3, 4, and 5; and the mealybug alone makes the 9th. Neither the mealybug nor the two bacteria can make phenylalanine on their own; they depend on each other to fill the gaps in their repertoires. This reminds me of the Graeae of Greek mythology: the three sisters who share one eye and one tooth between them. Anything more would be redundant: Their arrangement, though odd, still allows them to see and chew. So it is with the mealybug and its symbionts. They ended up with a single metabolic network, distributed between their three complementary genomes. In the arithmetic of symbiosis, one plus one plus one can equal one.

*********

The world around us is a gigantic reservoir of potential microbial partners. Every mouthful could bring in new microbes that digest a previously unbreakable part of our meals, or that detoxify the poisons in a previously inedible food, or that kill a parasite that previously suppressed our numbers. Each new partner might help its host to eat a little more, travel a little further, survive a little longer.

Most animals can’t tap into these open-source adaptations deliberately. They must rely on luck to endow them with the right partners. But we humans aren’t so restricted. We are innovators, planners and problem-solvers. And we have one huge advantage that all other animals lack: We know that microbes exist! We have devised instruments that can see them.

We can deliberately grow them. We have tools that can decipher the rules that govern their existence, and the nature of their partnerships with us. And that gives us the power to manipulate those partnerships intentionally. We can replace faltering communities of microbes with new ones that will lead to better health. We can create new symbioses that fight disease. And we can break age-old alliances that threaten our lives.

From the forthcoming book I CONTAIN MULTITUDES: The Microbes Within Us and a Grander View of Life by Ed Yong. Copyright © 2016 by Ed Yong. To be published on August 9 by Ecco, an imprint of HarperCollins Publishers. Reprinted by permission.