Martin Rees has a simple message for those seeking solace in the stars. The end is nigh: humanity has only a 50-50 chance of surviving the 21st century. According to the Astronomer Royal, nuclear war, biological terrorism, ecological mayhem or asteroid collisions could take us out in less than 100 years.

Nor should these warnings be dismissed as the musings of a mere depressive. They are the considered thoughts of one of the world's greatest astrophysicists, a man who has used his cosmological expertise to bring a new awareness of the risks to Earthly life. Outlined in his latest book, Our Final Century, Rees's prognostications demonstrate the perspective gained when our antics are viewed from an astronomical perspective. (Forget the asteroids, at the end of the day, it's most likely to be the A-bombs that do for us, he concludes.)

Rees's top-down approach to intellectual life is intriguing enough but takes on an immediacy given his new role in British public life - as the next president of the Royal Society, the world's oldest scientific academy and arguably its single most influential academic organisation. For the first time in 100 years, an astronomer is now at its helm.

Rees's selection was confirmed on Wednesday when the Royal Society's council agreed to propose him as its 59th president. Voting forms are now being sent out to the society's 1,200 members across the Commonwealth, though the fact these ballot slips contain only one name - Rees's - suggests the result will not be a nail-biter (following his election, he will have to stand down as Astronomer Royal).

Thus this grey-maned, hunched figure of Martin John Rees - he has suffered from curvature of the spine since adolescence - will join Isaac Newton, Humphry Davy, and Ernest Rutherford as head of the Royal Society, a post that is not without hazards, as many of Rees's predecessors have discovered.

In the late 18th century, the society, which was founded in 1660, conducted trials of the first lightning conductors and concluded Benjamin Franklin's were the best. Sir John Pringle, then president, was summoned by King George III to explain why he was backing an upstart colonist. Pringle defended Franklin's design but shortly afterwards felt obliged to resign.

Other ventures have had happier fates, however, and reveal the extraordinary academic power of the Royal Society. It financed Captain James Cook's first expedition in 1768 and later used its influence to ensure that in 1779 his boats were not attacked by French or American warships - countries with which Britain was then at war.

And on 6 November, 1919, at a Royal Society meeting, the astronomer Sir Arthur Eddington revealed that observations, taken during a solar eclipse, showed that starlight was being deflected by the sun's gravitational field in a way that fitted Einstein's General Theory of Relativity. 'Revolution in science. New theory of the Universe. Newtonian ideas overthrown,' the Times announced the next day on its front page. Einstein became a global superstar - thanks to the Royal Society.

In those heady days, a society president did little more than bathe in the reflected glory of its members and dish out sherry to the government ministers who controlled their purse strings. (The society currently gets £40 million, mainly to fund young scientists.)

But science, and public attitudes to science, have changed in the last few years and recent presidents have been obliged not just to champion scientific views but to try to shape public opinions and reactions to them. Six years ago, the then president Sir Aaron Klug launched a furious attack on the medical journal the Lancet for publishing a study by Arpad Pusztai in which the maverick biologist suggested the processes of genetic manipulation could make plants and crops poisonous.

This attack was followed up by Klug's successor, Lord Robert May, the current Royal Society president, who upbraided Prince Charles in no uncertain terms for the support that he had given to the GM protest movement. 'One could occasionally wish that he took a wider spectrum of advice,' May remarked. Clearly times have changed. It is science, not royalty, that hands out the rebukes today.

Thus Rees takes over a post that has changed radically in recent years and which will plunge him into a quagmire of scientific controversies: stem cell research, nanotechnology, saviour sibling selection, climate change, and other issues. It remains to be seen how he performs, though most colleagues are confident he possesses the right stuff.

'Martin will be great,' says Baroness Susan Greenfield, president of the Royal Institution. 'He is direct, does not weasel words, lacks any kind of pomposity and is a first-rate speaker. These days politicians, journalists and scientists badly need to understand each other and Martin is just the man to help that happen.'

The only son of two Shropshire teachers, Rees had a relatively happy youth in which he revealed little interest in scientific matters and in the end only chose to pursue mathematics because the alternative - languages - were a lost cause to him. However, after graduating from Trinity College, Cambridge, Rees branched out into cosmology. In the Sixties, Cambridge had become a world centre for its study and was bursting with astronomical talent: Fred Hoyle was Plumian professor and Stephen Hawking was already a bright new star. At the same time, astronomers were making dramatic observations that showed the cosmos had been created in a Big Bang eruption 13 billion years ago and was peppered with exotic objects like black holes - collapsed stars so dense that light cannot leave their surfaces. This was the subject to follow, Rees decided.

From the start, the young scientist demonstrated a remarkable talent for synthesising astronomical observation into coherent theoretical frameworks. (In fact, he has never carried out experiments or made observations. The only telescope he possesses - in the Cambridge farmhouse he shares with his sociologist wife Caroline Humphrey- is an antique.) In 1973, Rees replaced Hoyle as Plumian professor before becoming the Institute of Astronomy's chief in 1977. After that, he swept up dozens of visiting professorships, prizes and posts, culminating in his 1995 appointment as Astronomer Royal.

At the same time, his imagination continued to rove the universe and he has played key roles in providing theoretical muscle to a number of critical cosmological issues. Scientists had long been puzzled by bursts of gamma rays that satellite detected in space in the Sixties. Some argued that the sources must be local and relatively puny.

But Rees, and others, were adamant they were distant and colossal. In fact, we now know that gamma-ray bursters are incredibly remote and are also the biggest bangs the universe has experienced since the Big Bang itself. In a few seconds, as much energy as will be released by the sun in its 10,000,000,000-year lifetime is blasted into space - either by a giant exploding star or super-dense neutron stars colliding.

It is boggling stuff, but meat and drink to Rees who has also continued his investigations of the 'universe's dark ages' when stars first formed and foun dations of galaxies were laid down.

This is not the output of an ivory tower loner but of an enthusiastic academic team-player. Indeed, according to an analysis of international scientific papers, carried out by the Sante Fe Institute, Rees is the world's most collaborative physicist, and is linked as an author with more scientists than any other researcher. Step forward science's answer to Kevin Bacon who has played a similar pivotal linkage in appearances in Hollywood films.

Nor has Rees been afraid to share his cosmological thoughts and has produced a stream of elegantly-written popularisations: Our Cosmic Habitat , Gravity's Fatal Attraction , not to mention Our Final Century - which he has promoted with energetic, if not to say obsessive, enthusiasm. Whatever else, Rees is no aloof, snooty Oxbridge don.

His politics are 'old Labour', he says, and at the last general election, he happily endorsed Blair's government: 'The best the country has had since Clement Attlee's,' he insists. Following the Iraq war, which he opposed, Rees's backing has become more strained, though he insists he will still vote Labour on 5 May.

Such support should not be taken for granted by Labour, however. Rees fully endorses his recent predecessors' interventionist stand and is clearly bursting to have a punch-up - alright, a rigorous debate - over a number of issues, in particular the question of UK energy generation. Most of our nuclear power plants are old and will soon need decommissioning, he points out. Will we replace them with new nuclear plants, or wind turbines, or turbines that burn Russian gas, or what? 'The government cannot fudge this one any longer,' Rees insists.

Should we get it wrong, then we could face a cold uncertain future with insufficient power to warm our homes. On the other hand, we could enhance global warming and trigger climatic mayhem, or we could even suffer a devastating nuclear meltdown. These are uneasy prospects. Rees, to his credit, has perfect credentials for dealing with them.