By Kylie MacLellan and Elizabeth Piper

LONDON (Reuters) - Justice Secretary Michael Gove, one of the main campaigners to take Britain out of the EU, said on Thursday he would run to become prime minister, shaking up the contest and hurting the chances of his Brexit ally, ex-London mayor Boris Johnson.

Last week's EU referendum vote, when 52 percent of Britons voted to leave the bloc, triggered a political crisis in Britain with Prime Minister David Cameron stepping down. His replacement will face tough talks with Europe to mend a broken relationship.

On Thursday, Theresa May, the interior minister who campaigned to remain in the EU, also announced her candidacy to lead the party. But it was the surprise announcement by Gove that rocked the contest, by putting a second high-profile Leave candidate in the race against Johnson.

Gove, a close friend of Cameron's, had previously said he would back Johnson, but in a commentary in the Spectator magazine he said he had come "reluctantly, to the conclusion that Boris cannot provide the leadership or build the team for the task ahead".

His U-turn will hurt the chances of Johnson, who succeeded in widening his popularity among Conservative members and beyond as London mayor, but is viewed warily by many other lawmakers in the ruling party.

"If we are to make the most of the opportunities ahead we need a bold break with the past," Gove wrote.

Gove joins May and at least one other Conservative in a race to replace Cameron, who resigned after Britons rejected his argument to stay in the EU in a vote which exposed deep rifts in the country.

The main opposition Labour Party is also facing a potential leadership battle after its lawmakers voted no confidence in leftwing leader Jeremy Corbyn. The power vacuum is doing little to reassure jumpy markets and an increasingly angry electorate that the country can thrive on its own, outside the EU.

The Conservative Party has said it would select a new leader who can become prime minister by Sept. 9, and that it is moving as quickly as it can.

NO PRIVILEGE

Conservative members of parliament will narrow the field to two candidates, and the leader will then be chosen in a vote by party members.

Johnson has been the bookmakers' favorite, and several rivals launched their campaigns by underlining his privileged background -- he attended Eton, the same elite boarding school as Cameron -- and attacking his perceived lack of seriousness.

Some media have dubbed May the "Anyone But Boris" candidate.

In an article in the Times newspaper, she took aim at Johnson's jokey persona by saying government was not "a game".

She appealed to the working classes, many of whom voted to leave the EU in protest at an elite who, they say, has failed to cushion their lives from increasing competition. She also said the referendum decision would count.

"Brexit means Brexit," she told a news conference.

"The campaign was fought, the vote was held, turnout was high and the public gave their verdict. There must be no attempts to remain inside the EU, no attempts to rejoin it through the back door and no second referendum."

Stephen Crabb, the cabinet minister in charge of pensions and welfare, declared his candidacy on Wednesday, also seeking to distinguish himself from the "Eton elite". He pitched himself as a "blue collar" candidate, one who had worked up from a job in a local shop.

Liam Fox, a former defense secretary who backed Brexit, said he would also put himself forward.

(additional reporting by Estelle Shirbon, William Schomberg, Guy Faulconbridge, Editing by Peter Graff)