When Anis Amri drove a hijacked lorry into a Berlin Christmas market, killing 12 and injuring dozens more, emotions ran high. It was the week before the festivities, in the heart of Berlin, and the Christmas markets occupy a particular place in German hearts. The sense of violation and the outraged sympathy for the victims were both profound.

But what of the political fallout? With a general election next autumn, Angela Merkel committed to seeking a fourth term and her time as Chancellor so closely identified with Germany’s asylum policy, surely anything that so much as hints at a connection between the country’s generosity to new arrivals and an increased threat to its citizens is bound to spell electoral danger. At least, this was the immediate gut reaction – and mine, too. But it was quickly tempered.

Merkel herself showed characteristic calm and restraint in the wake of the attack. She refused to be hurried, addressing the nation only the next day. It was with sorrow rather than anger that she broached the possibility that the perpetrator had abused German hospitality, and she thanked all her many compatriots who had been helping with the reception of refugees.

Germans, by and large, have taken their cue from her. A subsequent survey, commissioned by Stern magazine, found that only 28 per cent of those asked agreed that Germany’s asylum policy contributed to the Berlin attack, while 68 per cent saw no link at all with asylum policy. It is good news for Merkel and suggests that her chances of leading the centre-right CDU/CSU alliance back into government have barely been troubled, let alone scuppered, by what happened in Berlin. Not only that, but the same survey showed the CDU/CSU gaining two points in the polls, as more trusted on security matters.

Angela Merkel reacts to shooting of Berlin market attack suspect

Yet I wonder whether this is all quite as it seems – and, specifically, whether Merkel is quite as certain to gain a fourth term as is assumed.

Take that latest Stern poll. It looks reassuring, but if you were a German, and asked that question about asylum policy and the Berlin atrocity, how would you have answered? You know what is expected of a good modern German; you know that it is wrong to generalise from the particular. You know that all faiths deserve respect and that Islam is a peaceful religion. You know that the vast majority of asylum-seekers are desperate for a place of safety and you were proud of your country’s response to their need.

But how deep do these attitudes run? When you see so many recent arrivals with little prospect of work and hear of the difficulties already besetting integration programmes, how will you vote in the secrecy of the polling booth? It wasn’t Stefan or Manfred who commandeered that lorry, and then drove it into the market beside Berlin’s Memorial Church. It was a failed Tunisian asylum-seeker who left a video in which he pledged allegiance to Isis. The least that can be said of the Berlin attack is that it was a one-off act, committed by a lone criminal with a cause.

Nor is the public mood the only reason why the Chancellor might be less secure than she seems. As Merkel herself has admitted, the Berlin attack raises some serious questions about German security. Amri had been under surveillance, but his tracks were lost. He was free to launch his attack because, it appears, although he had been refused asylum in Germany, the deportation papers were not ready. He was then able to leave Berlin and reach Italy undetected. With an investigation now in train and Merkel herself the author of German asylum policy, the buck could ultimately stop with her.

A forceful consensus maintains that she would be safe in her job even then, for the simple reason that there is no one else to seriously challenge her. In party political terms that is true; whatever happens in September, the right-wing Alternative for Germany (AfD) is not going to top the poll and if security is a central issue then Merkel’s centre-right CDU/CSU alliance will always be preferred to the centre and further left.

On the personal front, however, the same argument fails to convince. Seen from abroad, including from the UK, Merkel might look even less open to challenge than she does from within Germany. She is the linchpin of Europe, the admirably consistent proponent of European values, the indispensable leader. But since when has the lack of a plausible alternative prevented the removal of a leader who is thought to have become an electoral liability? Think Margaret Thatcher. Think Tony Blair.

Berlin Christmas market lorry attack Show all 18 1 /18 Berlin Christmas market lorry attack Berlin Christmas market lorry attack Several people have been killed after a lorry drove into crowds at a Christmas market in Berlin REUTERS/Fabrizio Bensch Berlin Christmas market lorry attack 'At least nine' people have been killed and more than 50 injured. AP Berlin Christmas market lorry attack Emergency Services rush a Berlin market victim to an ambulance Associated Press Berlin Christmas market lorry attack Police cordoned off the square at Kaiser Wilhelm Memorial Church following the incident REUTERS Berlin Christmas market lorry attack Rescue workers inspect the lorry that crashed into a Christmas market close to the Kaiser Wilhelm memorial church in Berlin EPA Berlin Christmas market lorry attack Emergency crews inspect the lorry that ploughed into a Berlin Christmas market, killing at least nine people AFP Berlin Christmas market lorry attack Fire crews attend the scene of the attack AFP/Getty Berlin Christmas market lorry attack Armed police secure the site of a lorry attack at a Christmas market in Berlin REUTERS Berlin Christmas market lorry attack Crushed debris is visible beneath the wheels of the vehicle REUTERS Berlin Christmas market lorry attack An injured man is pushed to an ambulance REUTERS Berlin Christmas market lorry attack Medics attend an injured person after the lorry attack which killed at least nine and injured more than 50 people AFP/Getty Berlin Christmas market lorry attack Firefighters examine the lorry which was rammed into a Berlin Christmas market REUTERS Berlin Christmas market lorry attack A person is carried into an ambulance REUTERS Berlin Christmas market lorry attack View of the lorry that crashed into a Christmas market in Berlin, killing at least nine and injuring at least 50 people AFP/Getty Berlin Christmas market lorry attack Rescue workers push a person on a stretcher to an ambulance Getty Berlin Christmas market lorry attack Firefighters assess the damage after the lorry rammed the Christmas market, killing 'at least nine', and injuring more than 50 people AP Berlin Christmas market lorry attack Firefighters stand beside a toppled Christmas tree at the site of the suspected terrorist attack in a Berlin Christmas market AP Berlin Christmas market lorry attack Damaged stalls at the scene of the incident at a Berlin Christmas market where at least nine people have been killed EPA

Merkel herself was a little-known politician from the East – certainly not someone seen as destined for great heights – when she brought the downfall of Helmut Kohl, the great patriarch of the CDU who had presided over reunification. There will be those in the wings, watching and waiting. If this Chancellor is at risk, the greatest threat will come from within.

Internal pressure has already forced restrictions on her open-door policy. She has curbed the rights of some refugees to permanent residence and tried to increase deportations. She has announced a largely symbolic ban on the full-face veil in some public places. The real crunch will come if a sufficient number of party dignitaries loses confidence in her ability to lead and demand concessions she feels unable to make.

This New Year’s Eve will be the next big test – less for the country’s security against terrorist attack, though that too – but to ensure there is no repetition of what happened last year. You can bet your last euro that German police will be out in force and that everything will be done to ensure that everyone, but especially women, feel safe on city streets.