Some microbes have developed the ultimate stripped-down diet. They do not bother with food or oxygen. All they need to survive is pure electrical energy.

They often live in muddy seabeds or along the banks of rivers. Finding them is easy: biologists can coax them out of hiding by sticking an electrode into the sediment. The bacteria nearest to the electrode will even grow biological equivalents of electrical wires out of their bodies, so that other microbes further away can hook up to the electricity source. It is effectively a living power grid.

What's more, it appears that we can all benefit from this microscopic grid. Among other things, it might provide an effective way to deal with toxic waste and other forms of environmental pollution.

Electricity-eating microbes might sound like something straight out of a science fiction novel. In fact their behaviour is not quite as exotic as it might first appear.

Whether the organism is a single-celled bacterium or a blue whale, it has to find a source of electrons

All lifeforms on Earth – even humans – must harness energy if they are to remain alive. This energy comes in the form of electrons, the same tiny negatively-charged particles that create a current when they zip around electrical wires in a circuit.

We humans, along with most other organisms on this planet, get our electrons from sugars in the food that we eat. In a series of chemical reactions that happen inside our cells, the electrons are released, and ultimately flow into oxygen – the same oxygen which we have just breathed in through our lungs. That flow of electrons is what powers our bodies.

This means that the challenge for all creatures is the same. Whether the organism is a single-celled bacterium or a blue whale, it has to find a source of electrons, and a place to dump them to complete the circuit.

But what happens when there is no oxygen to dump your electrons onto?

Many organisms live in low-oxygen environments and so must use alternative electron dumps. For some, that means "breathing" metals instead of oxygen.

Geobacter bacteria are able to survive on energy sources entirely unavailable to most lifeforms

In 1987 Derek Lovley and his lab at the University of Massachusetts stumbled across the first of these bacteria on the banks of the Potomac River near Washington DC.

The microbes, called Geobacter metallireducens, were getting their electrons from organic compounds, and passing them onto iron oxides. In other words they were eating waste – including ethanol – and effectively "breathing" iron instead of oxygen.

Of course, this is not breathing as we would recognise it. For one thing, bacteria do not have lungs. Instead, the bacteria pass their electrons to metal oxides that lie outside the cell.

They do this through special hair-like wires that protrude from the cell's surface. These tiny wires act in much in the same way that copper wire does when it conducts electricity. They have been dubbed "microbial nanowires".

Geobacter bacteria are able to survive on energy sources entirely unavailable to most lifeforms.

Biologists can coax them out of hiding by sticking an electrode into the sediment

They are even able to effectively "eat" pollution. They will convert the organic compounds in oil spills into carbon dioxide, or turn soluble radioactive metals like plutonium and uranium into insoluble forms that are less likely to contaminate groundwater – and they will generate electricity in the process.

In fact, some even see a future in which microbial fuel cells power devices like smartphones using seaweed, urine or sewage as their only food source: the ultimate in recycled energy.

In 1988, a year after Lovley's discovery, microbiologist Kenneth Nealson of the University of Southern California found a second electron-excreting bacterium.

He was investigating a strange phenomenon in Oneida Lake in New York State. The lake contains manganese, which reacts with the oxygen in the air to form manganese oxide.

However, Nealson did not find as much manganese oxide as he was expecting. Some of it was missing. The culprit, it turns out, was Shewanella oneidensis.

They can effectively "eat" electrons from minerals and rocks

This bacterium breathes oxygen when it is available, but in the muddy banks of the lake where oxygen is scarce it instead passes its electrons directly onto manganese oxide, producing a stream of electricity. It can do the same thing with other metals like iron.

Just how the bacteria were doing this was a mystery until very recently.

Under the microscope, Shewanella appear to have long thin hair-like extensions of their outer membrane. These filaments were at first thought to conduct electrons along them like a copper cable, much like Geobacter. However, it turns out that the long filaments are only conductive when dried out in a lab.

Instead Shewanella appear to shuttle electrons out of their cells using transport molecules called flavins and "stepping stone" proteins embedded in the outer membrane called cytochromes.

So far we have only talked about bacteria that produce electricity when they breathe. But these electron-excreting microbes are not the only ones that researchers have found.

While most organisms get their electron fix from carbohydrates, some bacteria can harvest electrons in their purest form. They can effectively "eat" electrons from minerals and rocks. In a way, they are getting their electrical energy straight from the socket.

Annette Rowe, a graduate student of Nealson, has found six new bacterial species on the ocean floor that can live off electricity alone. All are very different to one another, and none of them is anything like Shewanella or Geobacter.

All you have to do is stick an electrode in the ground and pass electrons down it

Rowe took samples of sediment from the seabed in Catalina Harbour off the Californian coast, brought them back to the lab and inserted electrodes into them. She then varied the voltage of the electrodes to see whether the bacteria in the sediment would "eat" electrons from the electrode, or discharge electrons on to it.

She found that, when no other food source was available, the bacteria would happily take electrons directly from the electrodes. In their natural habitat, the bacteria likely take their electrons directly from iron and sulphur in the seabed.

Examples of electron-eating bacteria found by Rowe include Halomonas, Idiomarina, Marinobacter, and Pseudomonas of the Gammaproteobacteria, and Thalassospira and Thioclava from the Alphaproteobacteria.

Many more electron-loving bacteria have now been found. In fact all you have to do is stick an electrode in the ground and pass electrons down it, and soon the electrode will be coated with feeding bacteria. Experiments show that these bacteria essentially eat or excrete electricity.

The holy grail of electricity-loving bacteria would be having a species that could both eat and excrete electrons, and so could exist entirely on electricity alone without any other energy source.

The wires were several micrometres long, which is much longer than the cells themselves

According to Lovley, that grail has already been discovered. Some species of Geobacter, he says, can both directly transfer electrons to electrodes and also directly accept electrons from them.

In 2015, we learned that electron-eating and electron-excreting microbes can actually team up and pass electrons between each other, wiring themselves into a common electrical grid.

At the bottom of the ocean lie vast reserves of methane, released by microbes feeding on the remains of dead algae and animals as they sink down from the surface. If the methane escaped into the atmosphere the gas would exacerbate global warming, but luckily a consortium of microbes seem to keep it in check.

Different species of bacteria and archaea – ancient single-celled microbes similar to bacteria in many ways – team up to degrade the methane before it can get the surface.

Gunter Wegener from the Max Planck Institute for Marine Microbiology in Bremen wondered how the process worked. He collected samples of the microbes, which live at temperatures of 60C on the ocean floor, and put them under a scanning electron microscope.

This ancient form of electronic cooperation may have evolved billions of years ago

The microscope revealed thin wire-like structures protruding from the bacterial cells. Although only a few nanometres wide, the wires were several micrometres long, which is much longer than the cells themselves.

It seems that the bacteria use these nanowires to hook up with the archaea.

The archaea feed on electrons from methane, oxidising the gas to generate carbonate. They then pass the electrons on to their partner bacteria along the nanowires, which act like power cables. Finally the bacteria deposit the electrons onto sulphate, producing energy that the cell can use in the process.

The researchers have now identified the genes that coded for the production of these nanowires. It is only when methane is added as an energy source that the genes are switched on and the nanowires form between bacteria and archaea.

This ancient form of electronic cooperation between the two types of microbe may have evolved billions of years ago, when the Earth's atmosphere was oxygen-free.

Some bacteria can link up to form long "cables"

"One of the most interesting developments in the area of microbes eating and breathing electrons is the concept of direct interspecies electron transfer," says Lovley. "This is when microorganisms wire themselves together to share electrons, permitting them to carry out reactions that neither would be able to carry out individually."

Lovley and his lab have also discovered other communities of bacteria that are able to pass electrons directly to each other.

In the lab, Lovley showed that two species of Geobacter – G. metallireducens and G. sulfurreducens – survive by forming a conductive network of nanowires, through which electrons can be shuttled. G. metallireducens takes electrons from ethanol and then passed them directly to G. sulfurreducens using this electrical grid.

In a more extreme version of this process, some bacteria can link up to form long "cables".

Cable bacteria live on sea floors and river beds where there is little oxygen. Without oxygen, they have nowhere to donate their electrons.

Bacteria have been seen to attach themselves to conductive materials

To cope with this the cable bacteria, which belong to the family Desulfobulbaceae, form chains, one cell in diameter, extending thousands of cells and distances of several centimetres – a huge distance for a bacterium only 3 or 4 micrometres long – until they finally reach a habitat with oxygen.

The first bacterium in the chain, which lives in a low-oxygen habitat, takes electrons from sulphide and passes them onto the next bacterium. This bacterium then passes the electrons on to the next cell, and so on until the final bacterium in the chain can finally pass the electrons onto oxygen.

This means that bacteria living in seabed mud where no oxygen penetrates can access oxygen dissolved in the seawater above simply by "holding hands" with other bacteria. Running along the chains of bacteria are ridges that connect the cells together, possibly allowing electrons to flow between them.

Other bacteria rely on rocks and minerals to do all the hard work for them when it comes to eating and dumping electrons.

It is even possible that microorganisms in the human gut electrically interact with cells in the gut lining

Bacteria have been seen to attach themselves to conductive materials, such as the iron-rich mineral magnetite, in order to pass electrons between each other through the magnetite. It is thought that chains of magnetite can form, bridging the gap between the electron-donating and the electron-accepting bacteria.

The environments these bacteria occupy may seem exotic, but electron-eating and -breathing microbes can also be found in more familiar settings.

For instance, they have been discovered in the digesters that convert brewery wastes to methane. Inside one such brewery, Geobacter metallireducens was directly transferring electrons to another bacterium, Methanosaeta harundinacea, which was then passing the electrons on to carbon dioxide.

It is even possible that microorganisms in the human gut electrically interact with cells in the gut lining.

Just why have the bacteria evolved this neat trick?

They have the potential to steal electrons from toxic waste, oil spills and nuclear waste

Being able to survive on electrons alone is a smart way of coping when resources and food are scarce, as can be the case at the bottom of the ocean or deep underground. Here, there is not quite enough energy for an organism to grow, or compete, but there is enough for it to exist – just about.

If life exists on other worlds, such as Mars or Jupiter's moon Europa, it will probably be in similarly sparse environments. Astrobiologists searching for evidence of extraterrestrial life might be particularly interested in electricity-eating and electricity-excreting microbes.

Whether or not such alien life is ever found, electricity-eating and -excreting bacteria here on Earth are still a significant discovery. All you need to do is provide them with an electrode onto which they can "breathe" electrons, and they have the potential to steal electrons from toxic waste, oil spills and nuclear waste, cleaning up our waste and generating electricity in the process.

Not bad for simple single-celled organisms.

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.