BERLIN (Reuters) - German police have detained a 26-year-old Tunisian man over links with the perpetrator of an Islamist truck attack on a Berlin Christmas market that killed 12 people, a federal prosecutors' spokeswoman said on Wednesday.

Police on Tuesday evening searched the living quarters of the man identified as Bilel A. after he was found to have had dinner with Anis Amri a day before Amri steered a truck through the market on Dec. 19, spokeswoman Frauke Koehler said.

"This contact person is a 26-year-old Tunisian. We are investigating him for possible participation in the attack," she told reporters.

Amri, 24, also a Tunisian and failed asylum seeker, was killed in a shootout with Italian police on Dec. 23 after fleeing Germany and traveling through the Netherlands, Belgium and France. Islamic State militants claimed responsibility for the Berlin attack.

Koehler said the investigation had shown Amri met the second Tunisian man in a restaurant in central Berlin on the eve of the attack and that the two engaged in "very intense discussions".

"That triggered the suspicion for us that the suspect, this 26-year-old Tunisian, was possibly involved in the act, or at the very least knew of the attack plans of Anis Amri," she said.

Koehler said there was insufficient evidence at this point to charge the man with any role in the Christmas market carnage, though had been previously investigated on suspicion of planning a violent attack.

Officials were evaluating communications devices seized during the raid of the man's accommodations in a Berlin refugee center, and in the course of a second raid the same evening at the flat of another man who had contact with Amri.

In a separate statement, the Berlin state prosecutor's office said it had detained the 26-year-old Tunisian on Tuesday for suspected social benefit fraud in three German cities.

A spokesman for the Berlin prosecutor's office said Bilel A. had used at least two aliases, Ahmad H. and Abu M., and also claimed to be Egyptian. He was believed to have arrived in Germany in 2014 or perhaps earlier.

Story continues

Berlin prosecutors in 2015 investigated whether the man had acquired explosives for an attack but dropped the inquiry in June last year for lack of evidence.

Koehler said Amri stared into a surveillance camera at a subway station near the Berlin zoo shortly after the Christmas market attack, and raised his index finger in a gesture sometimes seen in Islamic State propaganda videos.

She said forensic evidence showed that the Polish driver from whom Amri hijacked the truck was fatally shot while sitting in the passenger seat of the vehicle. The gun Amri used was the one found next to his body by police in Milan, Italy, she added.

Belgian prosecutors said on Wednesday Amri made a two-hour stopover at the Brussels North station on Dec. 21 after entering Belgium on a train from Amsterdam, before heading onwards to France.

(Reporting by Andrea Shalal and Michael Nienaber in Berlin, Alissa de Carbonnel in Brussels; editing by Mark Heinrich)