KANDEL, Germany — It happened between neatly stacked rows of shampoo and organic baby food: A teenage boy walked up to his ex-girlfriend in the local drugstore, pulled out a kitchen knife with an eight-inch blade and stabbed her in the heart.
The death in Kandel, in southwestern Germany, on Dec. 27 has traumatized this sleepy town of barely 10,000 inhabitants, not just because both the suspect and the victim were just 15 years old and went to the local school, but also because the boy is an Afghan migrant and the girl was German.
From the moment Germany opened its doors to more than a million migrants two years ago, prominent episodes like the Berlin Christmas market attack and the New Year’s molestation and rapes in Cologne have stoked German insecurities.
But the case of the two teenagers, Abdul D. and Mia V., has struck a special nerve because the killing happened in such a quiet and provincial setting and the two people involved were so young. It became national news, was debated over dinner tables, on talk shows and on social media sites, and reinforced fears that Germany is becoming ever less safe.
Yet perceptions are one thing, and statistics are another. Reported crimes have edged up over the past two years, but over all, violent crimes have been trending downward for a decade in Germany, which remains one of the safest countries in Europe.
Nevertheless, each crime involving a migrant or asylum seeker has become a fresh occasion for national hand-wringing.
Something has shifted in Germany. Not so long ago, the logistical challenge and cost of integrating new migrants still dominated the public debate. These days, the growing unease with Chancellor Angela Merkel’s migration policy has reached a new and febrile stage.
“I am scared,” said Jana Weigel, a 24-year-old dental assistant, as she lit a candle outside the DM drugstore where the killing took place.
Calls have multiplied for mandatory medical exams to determine the age of migrants claiming to be minors and for swifter deportations of those who — like the suspect — have been denied asylum.
A preliminary coalition agreement between Ms. Merkel’s conservatives and the more liberal Social Democrats announced on Friday includes a cap of 220,000 refugees per year and strictly limits the number of family members allowed to join a refugee in Germany.
Even in proudly tolerant and left-voting Kandel, the mood on the street has hardened. Many here took the killing personally. Before Mia broke up with Abdul, he had been welcomed into her family, Ms. Weigel pointed out, much like the hundreds of thousands of refugees who have been welcomed to Germany.
“It makes you think,” she said, “how many others will betray our hospitality.”
Ms. Weigel’s sense of insecurity was reinforced by a widely publicized study showing that the number of reported crimes in the state of Lower Saxony had risen by more than 10 percent over the past two years and that the increase could be attributed overwhelmingly to cases involving refugees.
Half of that increase is due to the fact that crimes involving migrants are twice as likely to be reported, the authors of the study said. Many of the people accused of crimes are young men under 30, a demographic that is most likely to commit crimes, even among Germans.
Less publicized was the other major finding of the report: Over all, violent crime, including murder and rape, remains well below its 2007 peak. The number of young offenders has decreased by half since then.
“The paradox is that Germany is still a very safe country, much safer than even a few years ago,” said Christian Pfeiffer, a criminologist and a co-author of the report, which was commissioned by the government and released last week. “But the perception is the opposite: People feel less safe. And when something like this murder happens, it confirms that feeling.”
Ask the Germans paying their respects at the ad hoc memorial for the girl who was killed — a sea of candles and messages and photos of her with friends — and they will reel off a list of crimes committed by migrants: a German woman who was raped by a Sudanese migrant in the nearby town of Speyer a few days earlier, another woman who was raped and strangled by an Afghan in Freiburg just over a year ago.
Ms. Weigel, who has a 2-year-old daughter, no longer leaves the house after dark. Last month, a terrorist attack was narrowly foiled at an ice rink in nearby Karlsruhe, a 30-minute drive away.
“It feels like we’ve lost control,” Ms. Weigel said. “The state has lost control.”
Kandel is an orderly town of tastefully restored medieval houses and shops that close for lunch. It is also home to 125 refugees, most of them from Syria or Afghanistan.
Until Mia was killed, “there was never a problem,” said Günther Tielebörger, Kandel’s mayor. He represents the Social Democrats, long the strongest party in the town. The far-right Alternative for Germany, or AfD, received less than 10 percent of the vote in the last election.
Kandel has a long tradition of tolerance. Three centuries ago, it welcomed Huguenot refugees from France. Where other villages in the region built a wall inside their churches to keep Catholics and Protestants apart, Kandel ripped down its wall and shared the church. One of the best restaurants in town serving regional specialties like “pig’s stomach” is run by a Turk.
But this tolerance is now being tested.
Maja Mathias, 53, works in a local French bakery and has Turkish neighbors and a Croatian brother-in-law. “I have no problem with foreigners,” she said, standing behind a counter featuring freshly baked baguettes and pretzels. “But there is always the fear: What else is coming?”
Beyond fear, the killing has stirred other resentments.
“German retirees who have worked hard for 45 years get less than the refugees,” said Knoll Pede, 64, a town maintenance worker. He is no fan of President Trump, he said, “but I wouldn’t mind our politicians to do a bit of ‘Germany First.’”
Such talk worries Mr. Tielebörger, the mayor. The benefits migrants receive are far less generous than Germans may believe, he said, and many of the migrants are barred from work until their asylum applications have been processed. But the optics matter.
“Germans feel neglected,” Mr. Tielebörger said.
“We need to wake up,” he said. Otherwise, he added, the left will lose votes to the right.
One of Mr. Tielebörger’s former colleagues in local government is Heiko Wildberg, a former member of the liberal pro-immigration Greens party. Mr. Wildberg is now a lawmaker for the nationalist AfD in Berlin. For him, Mia’s killing was a “turning point.”
“This is not Berlin or Cologne; we are in small-town Germany,” he said. “This murder shows that the reality of the migrant crisis has arrived in the German province.”
The AfD was quick off the mark, organizing a silent march through Kandel two days after the killing. The more extremist National Party of Germany followed suit.
Meanwhile, the local benefits office in Kandel had to barricade its doors because its employees had received so many threats. “Accomplices,” anonymous messages called them.
Some here accuse the authorities of not doing enough to protect Mia. Abdul had stalked her online and in person and beaten up one of her classmates in a fit of jealousy.
On Dec. 15, her parents had reported him to the police. Twelve days later, as she was shopping with friends, he stabbed her repeatedly with a knife he had bought in a supermarket next door. She later died of her wounds.
After her father told the German tabloid Bild that her ex-boyfriend “was definitely not 15,” demands for medical exams to verify the claims of refugees who say they are minors have been revived.
The ethics commission of the body representing Germany’s doctors has said that such tests — which include X-rays of hand, collar and jaw bones as well as genital exams — violate “bodily integrity” and can be inaccurate by up to two years.
They have nonetheless become a rallying cry at the highest level of politics.
“In all cases, where no official and real document is presented, we need to determine the age in another way, if needed through medical examinations,” said the conservative interior minister, Thomas de Maizière.
When Abdul arrived in Germany in April 2016, he said he was 14, and apparently none of the officials registering him raised serious doubts about his age. As part of the court case against him, a series of medical exams will now seek to confirm his age.
Austria, Sweden and the German state of Saarland are among the places conducting such exams regularly.
There is an incentive for migrants to be listed as under 18. Government benefits, access to German lessons and job opportunities are better for minors. In Saarland, more than a third of the migrants who were tested appeared to be over 18.
Most of the unaccompanied-minor migrants are integrating well, said Anne Spiegel, the integration minister for the state of Rhineland-Palatinate, which includes Kandel. “They are attending school, learning German and signing up for apprenticeships,” she said.
Still, officials like Mr. Tielebörger, the mayor, say that every transgression by a migrant gets disproportionate attention, leading to the opposite impression.
There was another shocking homicide in Kandel in recent weeks, he pointed out. A man killed his wife and two children. That one did not make the national news.
“If the boy had been German,” Mr. Tielebörger said, “we wouldn’t be having this conversation.”