In particular, foreigners who registered when they moved in, as required, apparently were leaving the country without ever deregistering. In the process they created what statisticians here call “card-index corpses,” phantom residents who lived on in the records long after having departed the country.

“Demographers were trying to explain the healthy-migrant effect, why they were living to be 110 years old,” said Steffen Kröhnert, a social scientist at the Berlin Institute for Population and Development. “It turns out they had moved back to their home countries and were only living in the registries.”

A rise in migration to Germany as job seekers from recession-racked countries like Spain and Greece sought work was one of the few bright spots, and it will have to be re-evaluated in light of the new figures. Germany is home to 1.1 million fewer foreigners than previously thought and 428,000 fewer Germans than expected, the study found. In all nearly 6.2 million foreigners live alongside roughly 74 million Germans.

The results reinforce a widespread belief in Germany that, although the country is the European Union’s most populous and the Continent’s largest economy, demographic decline poses special challenges. While politicians and economists in Paris and Washington call on Germany to spend more to pull the European economy out of its slump, Germans say they have to keep saving to prepare for the long run.

Who will pay for the pension system is an even more urgent question in Germany than in the United States, where the growth of the elderly population has raised worries about the future of Social Security. Germany has one of the lowest birthrates and oldest populations.

The Nazi regime abused demographic information. During the cold war, many on the political left believed that German law enforcement had been overzealous in the methods used to track down the terrorists of the Baader-Meinhof gang. The result was a backlash against the collection of personal data.

Shortly before a census was scheduled to begin in 1983, a court order disrupted it on the grounds that census data might be shared with other government authorities, like the police or tax examiners.