BERLIN — He left Tunisia, his family said, with dreams of making money and buying a car. After arriving in Italy, he was a violent inmate who spent time in six jails. In Germany, he was one of some 550 people identified as dangers to the state and placed under special surveillance.

Yet Anis Amri, who turned 24 on Thursday, was able to ignore deportation orders and brushes with the law, roaming freely until he apparently hijacked a truck and rammed it into a Christmas market in Berlin this week, killing 12 and wounding dozens. He was killed early Friday on the outskirts of Milan in a shootout with the police.

Mr. Amri’s life and odyssey underscore a vexing problem, common in Europe: how to handle hundreds of thousands of virtually stateless wanderers who are either unwilling or unable to return home.

Many are trying to integrate. Some are slated for deportation, only to melt into society. By their own intention or because of the authorities’ failings, some, like Mr. Amri, slip through the fingers of law enforcement.