Population decline has been described as "the greatest threat to the country's future prosperity" by First Minister Jack McConnell.

In February he unveiled a number of steps to tackle the problem through the Fresh Talent initiative, including visas which would allow foreign students to stay and work in Scotland after they graduate.

Mr Macniven's report dedicated a chapter to migration, which highlighted that 1.5% of the population in the year before the last census had migrated to Scotland.

"Students are an interesting group of migrants," he said.

"More people come to Scotland for their higher education than leave to study elsewhere.

"About 30% of students from the rest of the UK who studied in Scotland stayed here to work, and about 20% of students from the rest of the EU."

Within the UK, Scots tended to migrate to London and the south west, with people from Yorkshire, the Humber and the West Midlands making the reverse journey.

Scotland's population rose slightly in 2003

The population in Scotland's larger urban areas is declining, with the exception of Edinburgh, while there has been growth in rural communities and the areas surrounding cities.

The registrar general said there were some "interesting trends" in marriage.

"There were more weddings in Scotland last year than in any year since 1994," he said.

"The increase is mainly 'tourist' weddings, where neither bride nor groom is a Scottish resident. But, in 2003, the number of 'Scots' couples rose by more than 800.

"Perhaps that was the effect of a change in the law in 2002, which allowed civil marriages outwith registration offices - which now account for over 10% of all weddings."

The number of marriages in 2003 was still about 10,000 below the figures seen in the 1960s, he added.

Cardinal Keith O'Brien, from the Catholic Church in Scotland, welcomed the increase in the marriage rate.

He said: "It is reassuring to see that couples increasingly consider marriage as the most stable basis for a long term relationship and see it as providing the most secure environment for bringing up children."