Germany attacks: What is going on?
After suffering a series of attacks in the summer, Germany has been in fear of further violence.
Those fears were realised on Monday, when a lorry ploughed into a Christmas market in Berlin, killing 12 people and injuring 48.
During one week in July, 10 people had been killed and dozens more injured in separate gun, bomb, axe and machete attacks. Three were in Bavaria and one in Baden-Wuerttemberg.
The authorities said the July attacks were not linked to each other - but there were concerns about escalating insecurity in the country.
This year's attacks detailed
On 19 December, a man ploughed a lorry into a busy Christmas market in the heart of Berlin. The driver fled the scene but was arrested nearby.
On 18 July, a teenage Afghan refugee hacked at passengers on a train in Wuerzburg with an axe and knife, wounding five. He was shot dead by police.
On 22 July, a German teenager of Iranian heritage shot dead nine people in Munich before shooting himself dead.
On 24 July, a 21-year-old Syrian refugee killed a woman with a machete and wounded five other people as he fled before being arrested. Later that day, a 27-year-old Syrian whose refugee application had been refused blew himself up outside a bar in Ansbach. Fifteen people were wounded.
Were they all terror attacks?
The attack on the Christmas market in Breitscheidplatz is being investigated as a "probable terrorist attack", according to German police.
The attacker's name and nationality have not yet been confirmed by authorities.
The attack in Wurzburg was claimed by so-called Islamic State (IS), while the Ansbach bomber had videos on his phone showing him pledging allegiance to the group, Bavaria's interior minister said.
The attacker's bomb was packed with metal fragments and he had been attempting to gain entry to a music festival which more than 2,000 people were attending.
However, police ruled out a political motive for the killings in Munich.
Gunman David Ali Sonboly was inspired by other mass shootings that had no political motivation, such as a school massacre carried out by 17-year-old Tim Kretschmer in Baden-Wuerttemberg in 2009.
Sonboly carried out his attack on the fifth anniversary of the 77 murders by far-right extremist Anders Behring Breivik in Norway.
Investigators in Reutlingen said the Syrian machete attacker knew his victim and the attack was probably to do with their relationship.
It is too early to know if the Berlin attack has any links to any of the others.
German government spokeswoman Ulrike Demmer said the July attacks were not connected and did not show a "consistent pattern".
Did mental illness play a role?
Sonboly had a history of mental illness. He had spent two months as an inpatient at a mental care facility in 2015, was depressed and feared contact with others, the Munich prosecutor's office said.
The suicide bomber in Ansbach had also spent time living in a mental care facility and had twice attempted to take his own life, officials said.
In Reutlingen, the attacker also showed signs of being mentally disturbed.
He was also already known to police for assault, theft and drugs offences, police said.
Is the refugee background relevant?
Security sources cited by DPA news agency said that the Berlin attacker was either an Afghan or Pakistani asylum seeker.
The big influx of refugees to Germany is already controversial, and the fact that three of the July attackers were refugees heightened the polemic.
The anti-immigration AfD party has already blamed Chancellor Angela Merkel for the Berlin attack, linking the incident to her decision to allow more than one million migrants into Germany last year.
There has recently also been a lot of discussion about an Afghan youth who has been arrested over the October rape and murder of a German student.
After this, the government urged Germans not to scapegoat migrants.
The government had previously said the risk of someone being a perpetrator of terrorism was not greater among refugees than among the general population.
"Most of the terrorists who committed attacks in Europe in the past months were not refugees," said Ulrike Demmer.
Should Germany expect more attacks?
Returning jihadists are known to have told investigators that so-called Islamic State was keen to recruit in Germany and the UK to boost its ability to carry out attacks in those countries.
"Their networks in these countries are not as close to criminal networks or as substantial as in francophone countries such as France and Belgium," said Raffaello Pantucci from the Royal United Services Institute (RUSI).
"Most Muslims in Germany are of Turkish origin and while there are Turkish jihadists present, it is more of an Arab story and has deeper roots in France and Belgium."
Ahead of the Berlin attack, prosecutors said a 12-year-old German-Iraqi boy had tried to blow up a Christmas market in the German town of Ludwigshafen in November.
The boy was arrested in December, and the German media reported concerns that he had been radicalised by IS.
Were German authorities prepared?
After the Berlin killings, Roderich Kiesewetter, an MP from German Chancellor Angela Merkel's ruling party, said the government had taken measures to lower the risk of terrorism in the country.
A review of French intelligence found that attacks there this summer could have been prevented if different forces and agencies had communicated with one another.
After the July attacks, Mr Pantucci expressed concern about excessive bureaucracy in Germany, a country that has different police and intelligence agencies for each region as well as federal agencies. He said plots could "slip through" if intelligence was not shared effectively.
Efforts to disrupt plots could also be hobbled because of German legislation preventing agencies from eavesdropping on citizens in the same way as their counterparts in the UK and US routinely do, Mr Pantucci said.
The German government is currently attempting to broaden the scope of the intelligence service, the Bundesnachrichtendienst, to collect data, but a proposed new law has not yet been passed.