Hungarian police briefly detained former Socialist Prime Minister Ferenc Gyurcsany and several other lawmakers during a protest outside the parliament building where the government passed laws the opposition sees as a blow to democracy.

Parliament, where the ruling Fidesz party has a two thirds majority, passed a key financial stability law despite objections by the European Union, which could jeopardise talks about a new financing deal with international lenders.

Hungary is trying to secure the deal with the International Monetary Fund and the EU to retain access to market funding next year, but informal talks have collapsed, leading to a downgrade in Hungary's debt rating to junk by Standard and Poor's.

Parliament also passed an electoral law, which critics say will change the electoral system in favour of Fidesz, and several other disputed bills, prompting opposition MPs to chain themselves to a barrier outside parliament in protest.

Gyurcsany, who headed two previous Socialist governments and is now a member of parliament, was forcibly removed from the protest along with several lawmakers from the green liberal opposition LMP party.

Police later detained the head of the Socialist party and several other Socialist lawmakers who tried to prevent LMP activists being taken away from outside parliament. Those detained were later released.

(Prime Minister Viktor) Orban's autocracy can no longer tolerate even peaceful opposition and protest, Gyurcsany told Reuters after he was released.

MP Gabor Scheiring told Reuters: I have come here as it's a shame for the governing majority that people have to defend parliamentary democracy with their own bodies.

They want to cement the flat tax, under which the majority of people end up worse off ... and the ruling majority of Fidesz wants to approve an electoral law today, with which they will take away the people's right to replace this government.

The financial stability law cements a flat personal income tax, which the opposition says would tie the hands of any future government.

A vice chairman of Fidesz said the protests were a political parody.

Police said in a statement that by chaining themselves to the barriers, protesters blocked the entry of MPs to parliament, and did not obey police requests to leave.

When due to the behaviour of the demonstrators, Parliament became inaccessible at all entries, police intervened and detained 26 individuals, the statement said.

Peter Kreko, political analyst at think tank Political Capital said the police action was unacceptable. These pictures which show police removing opposition lawmakers, well, we see such photos in undemocratic countries.

What the government can achieve with this is that its isolation from the West can become much stronger both economically and politically, and if the government goes ahead on this road, then there is no other outcome but failure.

Since it swept to power in 2010, Orban's government has tightened its grip on the media, curbed the rights of the top Constitutional Court, renationalised private pension assets and dismantled an independent budget oversight body.

EU OPPOSES TWO LAWS

On Thursday Orban rejected a European Commission request to withdraw two disputed laws in a move which could derail talks with lenders about the new financial deal, and which analysts say could trigger a full-blown market crisis.

European Commission President Jose Manuel Barroso had asked Orban to scrap two laws - the financial stability law and one on the central bank which the European Central Bank says infringes on the central bank's independence.

The Commission was assessing Hungary's response, the EU's executive said on Friday.

Given the importance of the matters at stake, these replies require an in-depth assessment, which is under way and which will be concluded as soon as possible. The Commission will decide on its next steps in the light of this analysis, spokesman Dennis Abbott said in comments emailed to Reuters.

Economy Minister Gyorgy Matolcsy told parliament the financial stability law was key to having stable budgets and debt reduction.

Parliament also on Friday passed several amendments to the central bank bill to bring the legislation into line with the European Central Bank's requests, but left some contentious parts such as the expansion of the Monetary Council.

It is due to vote on the central bank bill next week.

The bill is the latest in a series of conflicts with Brussels. The United States has urged Orban's administration to respect democratic freedoms.

After the S&P downgrade, which followed a similar move by Moody's in late November, it is only Fitch which has not yet moved to cut Hungary's debt rating to below investment grade.

Analysts have said it could take a market crisis for the government to reach a deal with lenders.

They (the government) will only become serious (about a financing backstop) after a crisis has developed and that is only the point at which they will accept conditionality, Peter Attard Montalto at Nomura said on Thursday.

(Reporting by Krisztina Than; Editing by Diana Abdallah)