The foundation of philanthropist George Soros has said it is closing its office in Hungary, blaming the move on an "increasingly repressive" environment.

Open Society Foundations (OSF), which funds non-governmental organisations (NGOs), says it will move its operation to the German capital, Berlin.

Hungarian Prime Minister Viktor Orban's right-wing government has said it plans to tighten restrictions on NGOs.

Re-elected last month, Mr Orban campaigned under a "Stop Soros" banner.

Mr Soros denies Mr Orban's accusation that his foundation is part of a plan to bring migrants to Europe in order to undermine nation states.

OSF has been under sustained verbal and legal attack by the Fidesz government for the past three years, the BBC's Nick Thorpe in Budapest reports.

Foundation president Patrick Gaspard said: "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."

He added: "It has become impossible to protect the security of our operations and our staff in Hungary from arbitrary government interference."

The government did not comment immediately on the decision.

What's the new law about?
The proposals, aimed at tightening rules for NGOs receiving funding from abroad, are based on national security concerns, the government says.

Fidesz officials and pro-government media accuse the groups of representing an unelected, meddling, liberal elite.

The measures include a 25% tax on foreign donations aimed at programmes supporting migration, security clearance for staff and a ban on any group deemed as a security risk.

Rights groups have denounced the law as a crackdown on critics of the government.

The legislation is expected to be one of the first laws passed by the new parliament in the coming weeks.

What does the foundation do?
Hungarian-born George Soros, 87, has spent $12bn (£9bn; €10bn), mostly through OSF, on civil initiatives to reduce poverty and increase transparency, and on scholarships and universities around the world, especially in Eastern Europe and the former Soviet Union, since the 1980s.

Earlier this year, it emerged that the OSF had donated £400,000 ($540,000) to a campaign group fighting to keep the UK in the EU.

Soros initiatives usually have a strong human rights component, which have made him the bogeyman of many nationalist and illiberal governments.

This has seen him come up against Mr Orban, who has declared war on liberalism.

What does Orban say?
Mr Orban, 54, is a strong Eurosceptic who was re-elected for a third consecutive term in a landslide after campaigning on an anti-immigration platform.

He promised to defend the country's borders and block migration by Muslims and refused to take part in the EU's refugee resettlement programme, putting him in conflict with the rest of the bloc.

On Monday Mr Orban said the "Stop Soros" package had been "one of the most important questions of the election", AFP news agency reports.

"Hungarians voted for it... what we said we would do, we will do," he said on a visit to Warsaw,

Before the election, Mr Soros was vilified by Fidesz with a poster campaign saying "Don't let Soros have the last laugh".