In a statement, Gelsenkirchen police said that they received a phone call warning them that the man was alone in his apartment, where he planned to use a gun to take his own life.
Because of the risk that the man might be armed, armed response (SEK) units were called in and the whole building evacuated on Tuesday afternoon.
The officers finally entered the flat guided by a police dog, but the man immediately aimed his weapon at the head of one of the officers, who fired at him at once, wounding him fatally.
A homicide investigation is now checking into the facts of the case.
Police in Germany rarely fire their weapons at people. Statistics compiled by Dr. Clemens Lorelei at the Hesse University of Applied Sciences show that 10,779 shots were fired by police officers in 2013, of which 100 were against people.
While 41 of those were warning shots, 42 were aimed directly at the person. Eight police shootings were fatal, while 20 people were wounded.
All of the shootings causing injury or death were classified as self-defence or in defence of others.