BERLIN — Straining to hold back tears, their once-white helmets and overalls smeared with dust, seven miners in Germany stepped out of a metal cage bearing the last lump of black coal that they would haul up from more than 3,000 feet below.

The men, at the Prosper-Haniel mine on Friday, handed the football-size chunk of coal to President Frank-Walter Steinmeier with the words “Glueck Auf.” This ancient miners’ greeting roughly translates as “good luck,” reflecting the uncertainty of a life spent prospecting deep underground.

The ceremony represented the end of an industry that laid the foundations for Germany’s industrial revolution and its postwar economic recovery.

“A piece of German history is coming to an end here,” Mr. Steinmeier told the miners. “Without it, our entire country and its development over the past 200 years would have been unthinkable.”