Using a hair-dryer's worth of solar power, a sophisticated device will hitch a lift on one of the last-ever space shuttles to try to answer key questions about the universe. But it so nearly didn't fly, writes Robin McKie

We are in a windowless, airtight room in a basement at Cern, in countryside outside Geneva, where dozens of scientists are gathered round a huge, drum-shaped device. They make an odd sight. Each is kitted out in clean-room togs of nylon coats, plastic slippers and hairnets. Some clutch clipboards. Other stare into computers linked, via a maze of cabling on the floor, to the 10-tonne machine in the centre of the room.

In total, more than 500 scientists from 56 institutions across Europe, China and Taiwan have worked in these conditions to provide free labour and expertise to build the Alpha Magnetic Spectrometer, one of the most complex and controversial instruments ever built to carry out astronomical research.

In the midst of this apparent scientific confusion, the impassive figure of the Nobel prize-winning physicist Sam Ting orchestrates proceedings as if by telepathy. He rarely speaks and never smiles. "Enjoy!" was his only utterance to me when I joined his group of assistants to watch them in action. I discovered later that this represented an unusually effusive greeting for the 74-year-old physicist.

Such paucity of speech contrasts dramatically with Ting's ambition, however. He has laboured for the past 15 years to build an instrument that is likely to be flown on the last-ever mission by the space shuttle to the International Space Station where, for the next three years, it will survey the skies in a bid to answer key questions about the universe. Where do cosmic rays come from? Could there be galaxies made of antimatter on the other side the universe? And what is the true nature of dark matter?

Scientists consider the AMS to be a masterpiece of space engineering. It fits snugly into the hold of the space shuttle but exploits the same technology that is used to run giant particle colliders like Cern's Large Hadron Collider (LHC) – including a super-conducting magnet whose currents will be chilled to minus 270C. "Basically, the AMS is an all-purpose particle detector moved into space," says Ting, who is based at the Massachusetts Institute of Technology.

Such scientific sophistication is all the more the striking because the Alpha Magnetic Spectrometer is destined to be the only instrument capable of carrying out any kind of serious research on the space station, which has been heavily criticised for the flimsiness of its scientific aspirations. It possesses no other dedicated specialised equipment. Experiments carried out there will be limited to fairly trivial research on materials and biology in zero-gravity conditions. In 2002, a US National Academy of Sciences report described the station as a waste of money that would "never achieve the status of a world-class research laboratory".

The one exception to such criticism is the AMS. Its scope and design are groundbreaking. It will study cosmic ray particles that have energies comparable with particles created by the LHC (the largest particle accelerator ever built). Yet the AMS will run on only 2.5 kilowatts of power – less than that needed to run a hair-drier – which will be generated by its solar panels.

"The official price of the AMS is $300m," says Professor Martin Pohl of Geneva University, a team leader for this project. "But if you add in the cost of scientists' time, as well as the cost of the shuttle launch, which is America's contribution to the project, then you get a price tag of more than $1.5bn, which is close to that of the LHC. But then this is a very special machine."

Special it certainly is, but the AMS has also proved controversial and its inclusion in the station's construction has been bedevilled by political intrigue. The US National Aeronautics and Space Administration (Nasa), under the leadership of its previous administrator, Michael Griffin, flatly refused to fly the device to the space station. Particle physics had no place there, it was decreed, and for many years it seemed as if the AMS would end up languishing in a Nasa storeroom despite the vast sums spent on its construction.

Cosmic rays were discovered in 1912 by the Austrian physicist Victor Hess. On balloon flights, he found that atoms of nitrogen, oxygen and other gases were being ionised in increasing numbers as he gained height. Some form of radiation was beaming down on Earth and knocking electrons from atoms of these gases in the upper atmosphere, he realised.

These mysterious interstellar visitors were subsequently called cosmic rays, though today we know they are not actually rays. They are sub-atomic particles – mostly protons and alpha particles – that stream down on our planet at colossal energy, sometimes travelling close to the speed of light.

The origin of these emanations remains a mystery, though scientists do have their ideas. "The lighter cosmic ray particles are probably leftovers from the Big Bang," says Professor Pohl. "The heavier ones were probably blown into space by supernovae explosions." It will be one of the key tasks of the AMS to solve this mystery.

The device is, in effect, a large tube surrounded by a powerful, super-conducting magnet. The mighty field it generates will deflect particles as they fly through the tunnel while instruments, similar to those used in the LHC, will determine the charge, mass, velocity and energy of those particles.

"Basically, we will point it at deep space and see what comes through," says Chris Tutt, one of the project's US managers. This is a crucial point, for it is not just cosmic rays that scientists expect to fly into the AMS. They have a whole shopping list of other entities they hope will pop up in its detectors, including that most mysterious of substances, antimatter.

Theories indicate that equal amounts of antimatter and normal matter should have been created in the Big Bang. Thus the universe should have its fair share of antimatter galaxies. These in turn should be filled with antimatter stars with their own antimatter worlds. If we take the idea of this mirror-image universe far enough, we could envisage these antimatter worlds containing antimatter people who live in antihomes and sit on antichairs with anti-antimacassars on the back. At least that's the theory. Unfortunately, despite considerable efforts, researchers have found not a single atom of antimatter in their searches.

A brief flight by an early version of the AMS on the shuttle in 1998 revealed no signs of antimatter, while a joint Russian-Italian probe called Pamela – the Payload for Antimatter Exploration and Light Nuclei Astrophysics – has drawn a similar cosmological blank. These experiments have worked on the assumption that just as normal cosmic ray particles are produced by stars made of normal matter, then antimatter cosmic rays should be detectable if they are being sprayed into space from antimatter sources. An anti-particle which enters the AMS tunnel will bend in the opposite direction to a normal cosmic ray particle because it has a different electrical change and the AMS's detectors will reveal its presence.

"The AMS is designed to tell the difference between positively charged and negatively charged cosmic rays," says Pohl. "So if we start picking up heavy particles of antimatter that means that somewhere nearby there is a pocket of antimatter. It could even mean there is antimatter star near us. Imagine!"

In fact, Pohl is pretty sure that anti-matter from a local star will not pop up on the AMS's detectors. At very best, it may pick up one or two heavy ions of antimatter that have hurtled towards us from an antimatter galaxy at the other end of the universe. "We have already found on our brief early flight of AMS on the space shuttle that there is no sign of the stuff in our galaxy or even in our local cluster of satellites.

"I don't think we will find anti-matter," he adds, "and in a way that is a far more fascinating prospect. We have had 13 billion years for the universe's antimatter to disappear but we have no idea how that could have happened. It will therefore be more fascinating not to find antimatter than to find it. We will learn more from not observing something than from observing it."

This is a mouth-watering prospect if you care about the structure of the universe. Nor is issue of antimatter's existence the only contentious issue that AMS may help resolve. There is also the prospect that it will detect dark matter. Astronomers are convinced that as yet undetected particles permeate the universe providing galaxies with extra mass. Some of these strange little entities may show up on the AMS's instruments and open up a complete new chapter in cosmological physics.

Certainly, great things are expected of the AMS, which makes the battle to fly it to the space station so remarkable. In the end, faced by the intransigeance of Nasa, Ting lobbied the US Congress, backed by Nobel laureates such as Steven Weinberg. "Ting may say little but when he wants something he can be very persuasive," says Steve Myers, Cern's director of accelerators.

For his part, Weinberg was unequivocal. Results from the AMS would be the only significant science ever done on the space station. This device could make discoveries that are earth-shattering. Nasa chief Michael Griffin was hauled before a hearing in 2008. "It is almost like cutting off our nose to spite our face," said a dismayed Bill Nelson, the Democrat senator for Florida. A year later, Griffin was replaced by the current Nasa chief, Charles Bolden. "Five days later, we were back on the launch manifest for the space shuttle," says Pohl.

Finally, an act of Congress was passed to ensure that the AMS would be flown to the space station before the US shuttle fleet is grounded at the end of this year. This flight is currently scheduled to take place in July, on the penultimate shuttle launch, although Pohl has warned the AMS is unlikely to be ready until the end of the year, most probably on the shuttle's very last flight.

If so, it will make a dramatic finale for the space shuttle, for the AMS will provide scientists, for the first time, with a complex detector, stationed outside Earth's atmosphere, that will allow them to study high-energy particles in space. Anything could turn up in its detectors. As Sam Ting says: "We will be exploring whole new territories. The possibility for discovery is off the chart."