BERLIN — Angela Merkel is headed toward a fourth term as German chancellor and a far-right party will enter parliament for the first time in more than 60 years, according to normally reliable exit polls released just after the voting ended in Germany.
The far-right party, Alternative for Germany, got some 13.5 percent of the vote, a significant showing of voter anger over immigration and inequality as support for the two main parties sagged.
Despite her victory, Ms. Merkel and her conservatives cannot rule alone, making it probable that the chancellor’s political life will be substantially more complicated. The shape and policies of a new governing coalition will involve weeks of painstaking negotiations.
The center-left Social Democrats, Ms. Merkel’s coalition partners for the last four years, ran a poor second to her center-right grouping, and its leaders announced Sunday evening that the party would go into opposition, hoping to rebuild their political profile.
But the step was a way for Germany’s mainstream political parties to make sure that the far-right Alternative for Germany, or AfD, stays on the political sidelines and does not become as the country’s official opposition.
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.”