SOFIA (Reuters) - Bulgaria’s parliament speaker Dimitar Glavchev resigned on Friday in a move he said was to avoid political upheaval as the country prepares to take over the six-month rotating European Union presidency in January.

The opposition Socialists had demanded Glavchev’s resignation and said they would boycott parliament sessions until he stepped down after he banned their leader, Kornelia Ninova, from the chamber over what he called offences to deputies and members of the government on Wednesday.

Glavchev, who described his resignation as “a moral act”, said it was his intention to restore calm in the parliament and not cast a shadow over Bulgaria’s EU presidency.

“I have always said that the state and its stability are more important than anything,” said Prime Minister Boyko Borissov.

Parliament voted to appoint Tsveta Karayancheva, a senior member of the ruling center-right GERB party, to replace Glavchev.

“Glavchev made a mistake, but his resignation is just a preventative measure and it will not lead to a parliamentary crisis or the fall of the government,” Daniel Smilov, an analyst with Bulgaria’s Centre for Liberal Strategies, told Reuters.

“GERB is trying not to complicate the situation.”

The center-right GERB, led by Borissov, returned to power for a third term since 2009 after a snap election in March. His coalition government has a one-seat majority but is also supported by a small populist party.