BERLIN — In an unusually strongly worded warning, Germany’s domestic intelligence agency on Thursday officially classified a part of the far-right Alternative for Germany party as extremist and said it would place some of its most influential leaders under surveillance.

It is the first time in Germany’s postwar history that a party represented in the federal Parliament has elicited such intense scrutiny, and it points to an uneasy quandary facing the country’s institutions: What to do with a party that is at once considered a danger to democracy and that is gaining in popularity in parts of the country?

The leaders of the Alternative for Germany, or AfD, as the party is known, routinely attack the press, accuse Muslim immigrants of being criminals and question the universalist principles of liberal democracy. Yet the party sits in the federal Parliament, where it is the leading voice of the opposition.

The warning on Thursday was issued by the Federal Office for the Protection of the Constitution, whose founding mission after World War II was to protect against the rise of political forces — primarily another Nazi party — that could once again threaten Germany’s democracy.