BERLIN—Germany is making a “considerable” financial profit from the surge in immigrants, with its 6.6 million foreigners helping to fund the aging country’s costly welfare system, a study published Thursday showed.

Foreigners paid on average €3,300 ($4,127) more in taxes and social security contributions in 2012 than they took out in benefits, generating a €22 billion surplus for the public coffers that year, according to a study by the nonpartisan ZEW economic institute which was commissioned by the Bertelsmann Foundation.

...