LONDON — Prime Minister Theresa May survived an effort to oust her as head of Britain's ruling Conservative Party on Wednesday, leaving her standing but wounded as the government scrambles to negotiate Brexit just months before the U.K. is due to leave the European Union.

A majority of Conservative lawmakers chose to support her in a secret ballot that was triggered when at least 48 of her colleagues wrote letters demanding a vote.

If she had lost, May would have been forced to step down amid anger at her handling of the crucial Brexit talks and widening chaos over the manner of the U.K.’s divorce from the 28-member European bloc.

Instead, she now cannot be challenged again for a year.

May said she was pleased to have received the backing of the majority of her colleagues, but also listened to the concerns of those who voted against her.

"Whilst I'm grateful for that support, a significant number of colleagues did cast a vote against me, and I've listened to what they said,” May said at a news conference. “Following this ballot, we now need to get on with the job of delivering Brexit for the British people and building a better future for this country.”

Prior to the no-confidence vote, May told Conservative members of Parliament that she will step down prior to the next general election, which is currently set for 2022.

She said earlier Wednesday of the balloting on her leadership of the party, “I will contest that vote with everything I’ve got.”

The move to oust May came as lawmakers struggle to decide what the relationship between the U.K. and the European Union will look like after the March 29 Brexit deadline.

It wasn't just May’s leadership at stake, but how the U.K. exits the E.U., and whether Britain retains a close relationship with Europe, leaves with more independence or crashes out without agreeing to a deal.

Earlier this week, the prime minister was forced to postpone a pivotal parliamentary vote on the deal she negotiated with the E.U. which faced a crushing defeat by lawmakers.

Most members of Parliament hate the deal, with hardline Brexit supporters in May's own party accusing her of selling out.

But many of those same politicians have seemed reluctant to depose May altogether, fearing further chaos or even the prospect of the opposition Labour Party gaining power.

May took over as leader of the Conservatives — and the country — in July 2016, when David Cameron stepped down in the wake of the Brexit referendum. Cameron had called the vote in an effort to resolve the issue of the U.K.'s relationship with the E.U. — something that has divided the Conservatives for decades.

At the time May pledged to honor the referendum result.

She called an election in June 2017, seeking to consolidate her position and allow her to deliver Brexit.

Instead the Conservatives lost a slew of seats to Labour, leaving the fate of Brexit — and May — uncertain.

Now she must try to find a deal that can win the support of her bitterly divided party.