BERLIN—The tidal wave of refugees that crashed through Germany’s doors last year has long turned to a trickle, but the costs of the inflow will remain a burden on the country for years, budget figures released on Friday showed.

The German finance ministry expects to spend €77.6 billion ($86.2 billion) over the next four years feeding, housing and training refugees as well as helping their home countries to stem the flow, according to updated budget estimates for the period from 2017 to 2020. Adding budgeted costs for the current...