If you came to Germany for political or humanitarian reasons and want to stay here, you can apply for asylum. If your application for asylum has been approved, you will be issued a residence permit. In Germany, there are three different forms of protection for refugees: You may be recognized as an individual entitled to asylum, as a refugee or as a person granted subsidiary protection. Besides, the BAMF can also issue you a national ban on deportation (“nationales Absschiebungsverbot”). When your residence permit expires but the reasons for your protection persist, you can apply for a permanent residence permit or extend your residence permit further.
These forms of protection are only annulled when the condition in your country of origin has improved fundamentally, and repatriation is plausible. In other words, if your safety is still in danger in your country of origin, you may be able to remain in Germany permanently.
Everything depends on the type of residence permit you have and the law according to which it has been issued.