The Alternative for Germany nonetheless vowed to shake the consensus politics of Germany. Alexander Gauland, one of AfDâs leaders, told party supporters after the results that in parliament: âWe will go after them. We will claim back our country.â
To cheers, he said: âWe did it. We are in the German parliament and we will change Germany.â
While both Ms. Merkel and the Social Democrats lost significant voter support from 2013, her victory vaults her into the ranks of Konrad Adenauer and Helmut Kohl, the only post-war chancellors to win four national elections.
Now 63, the election is a remarkable capstone for her, the first East German and the first woman to become chancellor.
It also represents a vindication of her pragmatic leadership and confidence in her stewardship of Europeâs largest economy and of the European Union itself in the face of populist revolts, challenges from Russia and China and uncertainty created by the unpredictable policies of President Trump.
Ms. Merkelâs conservative bloc won 32.5 percent of the vote, according to the ARD exit poll â sharply down from 41.5 percent in 2013.
The Social Democrats slumped to 20.0 percent, a new post-war low, according to the exit poll, down from 25.7 percent four years ago.
If the Social Democrats hold to their intention to go into opposition, Ms. Merkel will be faced with an unusually difficult task to form a working coalition.
Given the numbers, it would seem that she will have to cobble together her own Christian Democrat-Christian Social Union bloc together with two other parties.
The new partners inhabit virtually opposite poles on the political spectrum â the pro-business Free Democrats, who won some 10.5 percent of the vote, and the left-leaning pro-environment Greens, who won 9.5 percent, again according to the ARD exit poll.
The two parties have radically different views on many topics, and Ms. Merkel also will face some quiet discontent from her Bavarian-based Christian Social Union, who have regional elections next year and are worried about losing votes to the AfD. At the Christian Democrat headquarters, Frank Wexler, a Berliner, called the results âa bit depressing.â
Grand coalitions had allowed the small parties to gain ground, he said. âThe main parties are getting smaller,â Mr. Wexler said. To counteract the AfD, he said, âWe need to address the issue of strengthening the borders.â
But Mr. Wexler said he was most disturbed by the AfDâs hostility to the European Union. âThis is what Germany needs to do â be a strong leader in Europe.â
Germans had been warned about the dangers of complacency in parlous times by their president, Frank-Walter Steinmeier.
He urged them to take their civic responsibilities to heart and not sit out the vote in the face of opinion polls showing Ms. Merkel and her center-right Christian Democrats and their Bavarian allies, the Christian Social Union, with a double-digit lead over the center-left Social Democrats.
âIt has perhaps never been as clear that the elections are about the future of democracy and Europe,â he wrote in the mass-market newspaper Bild am Sonntag, amid polls showing that as many as a third of Germans were undecided.
âIf you donât vote, others decide,â Mr. Steinmeier wrote.
The unspoken worry behind his intervention was the strong showing in the polls of the AfD, which began as a faction opposed to the euro currency and has morphed into an anti-immigration, anti-Islam party.
In a tweet, the Social Democrats urged people to get out and vote against the AfD, saying âa right-wing extremist party that doesnât belong in parliament.â
Frauke Petry, an AfD chairwoman, fired back with her own tweet: âLive with it comrades, the trend to the left is over today.â
On Sunday, #gehtwaehlen, German for âGo Vote,â was trending on social media, as Germans posted images and comments about casting their ballots in an effort to urge their peers to join them.
Germany has a complicated system of proportional representation, in which each voter casts one ballot for their local representative and one ballot for a political party. Those elected locally get their seats.
But the partiesâ overall share of seats in parliament is determined by the percentage of second votes they win.
So a low turnout â it was more than 71.5 percent in 2013, less than 1 percentage point more than the record low of 70.8 percent in 2009 â clearly benefits smaller parties, whose supporters tend to be more fervent and ideological.
Turnout appeared to be roughly the same as four years ago, however â a long way from the 90 percent turnout figures of the 1980s.
Though initially reluctant to run for a fourth term, Ms. Merkel threw herself into the campaign, especially as the government has brought some order to the chaos engendered in 2015 when she threw the countryâs borders open to refugees and migrants.
But the backlash over the migrant crisis, coupled with her long period in office and the wishy-washy nature of grand coalition politics, has led to more support for the more extreme parties like the AfD and The Left, the heir of the East German Communist Party.
In a separate vote in Berlin of interest to anyone who has ever flown into the city, Berliners are being asked whether to keep the small, convenient, Cold War-era airport, Tegel, even after the planned opening of the much-delayed new international airport farther from the city center town. The delays are widely mocked in Germany and abroad.
Although the referendum is nonbinding, voter support combined with numbers â this year, through July, Tegel has handled some 35 million passengers â could be enough to force politicians to reconsider its planned closing.
In Dresden, Gert FrÃ¼lling, 75, a retiree, declined to divulge his party preference, but made it clear that he was sympathetic to some of the Alternative for Germanyâs proposals.
âIt all happened too fast,â he said, referring to the time after Germanyâs reunification. âDresden is a city of bureaucrats and soldiers, and they dumped all this multiculturalism on us at once. I know we had to change, but it should have happened more gradually.â
He said it would be wrong for other parties to refuse to work with the AfD in Parliament. âIf they present good ideas,â he said, âI think itâs not fair to boycott them.â
In Neustadt, a gentrifying area of Dresden, Rebecca Klingenburg, 20, was clearly excited to be one of an estimated three million first-time voters.
âOne gets to decide on what country one wants to live,â she said. A mechanical-engineering student, Ms. Klingenburg said she was voting to maintain Germanyâs orientation toward Europe, at a time of rising nationalism.
âI learned four languages in school,â she said. âI want to make sure that we stay internationally oriented.â