The prime minister of Thailand was ousted from office Wednesday night in an abuse-of-power court ruling. 

The Constitutional Court made the decision to remove Prime Minister Yingluck Shinawatra, which is a controversial move in Thailand's polarized political struggle. The removal of Shinawatra comes at a time when the main parties in the tenuous democratic government cannot agree on elections, The Washington Post reports. 

Shinawatra has faced many challenges to her rule over the last six months, including protests and an investigation by an anti-corruption panel. 

Yet, the decision Wednesday came from a different case involving the transfer of a senior government employee three years ago. The court ruled that the transfer had a "hidden agenda," and that she manipulated positions so one of her relatives could become police chief. 

"Transferring government officials must be done in accordance with moral principle," the court said in its ruling.

The ruling, which aired on national television, was handed down by Thailand's highest court, and takes effect immediately. The ruling also removed all cabinet members who were in the cabinet at the time of Shinawatra's cabinet transfers. The remaining cabinet then appointed Niwatthamrong Bunsongphaisan as acting prime minister. 

Despite the protests against her rule, Yingluck, 46, has remained popular in pastoral areas. There is a sharp divide between rural and urban constituents since Yingluck's older brother, Thaksin Shinawatra, who was the country's first populist leader, was ousted in 2006 as part of a military coup.

Since his ouster, rural voters have voted in Thaksin-backed parties, but courts eventually remove them. Since 2006, the court has dissolved Thaksin-backed political parties and have ousted Thaksin-supported prime ministers three times, including Yingluck. Thaksin's supporters, who are known as the red shirts, claim the courts are partisan and want to return power to the elites of Bangkok. 

However, those who oppose Thaksin believe the telecom magnate perpetrated undemocratic corruption. 

Thaksin, who is now in political exile in Dubai, continued to advise Yingluck from exile. 

After the ruling, Yingluck continued to attest that she "never acted corruptly." 

Since last fall, more than 20 people have been killed in gunfire, grenades and clashes with police in protests against PM Yingluck. Yingluck then dissolved parliament and had an impromptu election, but many protestors blocked candidates from registering and people from voting. The election, which was held in February, was nullified and Yingluck remained in power. 

New elections are scheduled for July 20, but there are a series of obstacles that could prevent them from occurring. Some analysts say that the anti-government movement could try to put loyalists in power, or Yingluck's supporters could create a new round of protests. Or, the court's decision could appease anti-government protestors while also keeping the ruling Pheu Thai Party in power temporarily. 

"The question is whether the protesters will be satisfied with Yingluck's ouster and return to the electoral system," said Thitinan Pongsudhirak, a political scientist at Chulalongkorn University in Bangkok. "Or, will they continue to protest Yingluck's successor? If they continue to do that and reject elections, then we are back in the same place, and maybe worse."

Yingluck, who had been in power since 2011, had stability until last year, when Thaksin's government in parliament tried to push through a bill that would have cleared him of corruption charges and allowed him to return home. 

Thailand has had 18 coups since 1932, which is taking a toll on the country, which has one of the largest economies in Southeast Asia.