WARSAW — Under intense political pressure and the threat of legal sanctions, George Soros’s Open Society Foundations said on Tuesday that it had become impossible to work in Hungary, whose prime minister has blamed Mr. Soros for the country’s problems, and that the foundations would move their operations to Berlin.

The foundations, which promote democracy, free expression and civil rights, have come under growing political and legal pressure from Prime Minister Viktor Orban, who has stifled dissent and declared last week that “the era of liberal democracy is over.” The foundations have been a frequent target of the Hungarian government, and Mr. Orban himself has painted Mr. Soros as a shadowy figure seeking to undermine the country’s sovereignty.

“The government of Hungary has denigrated and misrepresented our work and repressed civil society for the sake of political gain, using tactics unprecedented in the history of the European Union,” Patrick Gaspard, president of the foundations, said on Tuesday.

The decision to close the groups’ offices in the country of Mr. Soros’s birth — they will continue to operate in many other countries — is the grim culmination of years of struggle to work in an increasingly hostile environment. Mr. Soros, 87, a Jew who survived the Nazi occupation of Budapest during World War II, later made a fortune in the financial markets, and he created the foundations and donated billions of dollars to them.