In a remarkable turn of events, Kevin Rudd, Australia's former prime minister, has returned to his post, roughly a month after endorsing gay marriage.

Julia Gillard, a staunch opponent of marriage equality, ousted Rudd as prime minister in 2010.

On Wednesday, Gillard faced her third leadership test since taking office. Rudd won by 57 votes to 45.

In a televised appearance after the vote, Gillard said that she respected the decision of her party.

The vote comes ahead of a general election to be held in September. Polls suggest that the Labor Party is on the outs and that Rudd is more popular with voters than Gillard.

Writing last month in a blog post, Rudd said that the had reversed course on the issue of gay nuptials.

“I have come to the conclusion that church and state can have different positions and practices on the question of same sex marriage,” he wrote. “I believe that the secular Australian state should be able to recognize same sex marriage.”

Rudd becomes Australia's first prime minister to support marriage equality.

Rodney Croome, national director for Australian Marriage Equality, described the turn of events as a game changer.

“Having a prime minister who supports marriage equality opens up a new chapter in the debate because, as we have seen in the US, New Zealand, France and Britain, such high-level leadership is crucial to achieving this reform,” Croome said.