Late Sunday evening, a 27-year-old Syrian refugee blew himself up at the entrance to a music festival in the Bavarian city of Ansbach. The blast killed him and wounded a dozen others, three of them seriously. According to Bavaria's Interior Minister Joachim Hermann, the man had tried to commit suicide twice before and was undergoing psychiatric treatment. The motive for his attack is not yet unclear.

The Syrian refugee was denied asylum in 2015, but stayed on in Germany under a special category called "Duldung," meaning that his presence would be tolerated. So he was officially allowed to remain until deportation to Syria was possible.

The attacker's case is somewhat unusual for migrants coming from Syria, which is on the federal government's list of the most unsafe countries of origin.

Who can get asylum in Germany?

According to Germany's asylum laws, a person who can prove that he is threatened by war in his home country has a good chance of staying in Germany.

Syrians have a nearly 100 percent chance of receiving asylum because of the war going on in their country, says the German Office for Migration and Refugees (BAMF). Economic migrants from the Balkans and North African countries, on the other hand, have fewer chances of getting permission to live here.

What happens when an asylum application is rejected?

Refugees are informed of the authorities' decision and must leave the country within 30 days. However, they have the option of appealing against the rejection. If their appeal is unsuccessful, they must leave Germany or be forcibly sent back by officials.

When can migrants stay despite being denied asylum?

There are several reasons why a rejected applicant is allowed to stay, despite a failed asylum request.

First, around 80 percent of refugees arrive in Germany with fake papers or no papers at all, making it difficult for authorities to trace their countries of origin.

Second, refugees are allowed to stay if they suffer from a health problem that makes traveling impossible.

Third, they are permitted to remain if the situation in their native countries "presents a concrete threat to life and limb or the freedom" of the person.

What does a "tolerated right to stay" mean?

A "Duldung," which literally means toleration, is not a visa, but a document that says a person is a legal resident of Germany. It also means that theoretically, the migrant can be deported at any time. Refugees need to apply for a new permit every six to 18 months and have restricted access to jobs and social benefits. They cannot move around freely and need to remain within a particular area.

According to figures published by the Federal Statistics Office in December 2015, Germany has 155,103 rejected asylum applicants living with a "Duldung."