"This triple system gives us a natural cosmic laboratory far better than anything found before for learning exactly how such three-body systems work and potentially for detecting problems with general relativity that physicists expect to see under extreme conditions," said Scott Ransom of the US National Radio Astronomy Observatory (NRAO) in Charlottesville, VA.

"This is a fascinating system in many ways, including what must have been a completely crazy formation history, and we have much work to do to fully understand it."

Pulsars emit lighthouse-like beams of radio waves that rapidly sweep through space as the stars spin on their axes.

They are formed after a supernova collapses a burnt-out star to a dense, highly magnetised ball of neutrons.

Using the Green Bank Telescope, the astronomers discovered a pulsar 4,200 light-years from Earth, spinning nearly 366 times per second.

Such rapidly-spinning bodies are called millisecond pulsars - and are used by astronomers as precision tools for studying gravitational effects and other phenomena.

Subsequent observations showed the pulsar is in a close orbit with a white dwarf star, and that pair is in orbit with another, more-distant white dwarf.

Three-body systems are keenly studied because they allow competing theories of gravity to be tested.

But until now the only known triple system containing a millisecond pulsar was one with a planet as the outer companion, causing only weak gravitational interactions.

"This is the first millisecond pulsar found in such a system, and we immediately recognised that it provides us a tremendous opportunity to study the effects and nature of gravity," Prof Ransom said.

"The gravitational perturbations imposed on each member of this system by the others are incredibly pure and strong."

By precisely timing the arrival of the pulses, the scientists were able to calculate the geometry of the system and the masses of the stars.

The pulsar's inner white-dwarf companion has an orbital period of less than two days, while the outer dwarf has a period of almost a year.

The system gives the scientists the best opportunity yet to look for violations of the equivalence principle described by Einstein - which states that the effect of gravity on a body does not depend on the nature or internal structure of that body.

This was famously illustrated by Galileo's dropping of two balls of different weights from the Leaning Tower of Pisa, and Apollo 15 Commander Dave Scott's dropping of a hammer and a falcon feather while standing on the Moon in 1971.

Rather than drifting to the ground, the feather plummeted, falling as fast as the hammer. Without air resistance to slow the feather, both objects hit the lunar dust at the same time.

"While Einstein's theory of general relativity has so far been confirmed by every experiment, it is not compatible with quantum theory," said Prof Ransom.

"Because of that, physicists expect that it will break down under extreme conditions."

High-precision timing of the pulsar's "lighthouse" flashes will let astronomers hunt for deviations in the equivalence principle at a sensitivity several orders of magnitude greater than ever before, said astronomer Prof Ingrid Stairs of the University of British Columbia.

"Finding a deviation would indicate a breakdown of general relativity and point us toward a new, correct theory of gravity," she said.