By Elizabeth Piper

LONDON (Reuters) - Britain's two main parties were in open conflict on Sunday after a vote to leave the EU triggered an attempted "coup" in the main opposition Labour Party and a bitter leadership contest in the ruling Conservatives.

Both parties are reeling from the referendum result, when British voters rejected the arguments of their leaders and decided to leave the European Union in a vote which underscored the deep divisions in the country.

Prime Minister David Cameron has said he will resign -- prompting a fierce battle to replace him -- and several Labour lawmakers quit the party's top policy team to try to force their leader, Jeremy Corbyn, from office.

It fell to Scottish First Minister Nicola Sturgeon to describe events as "a vacuum of leadership".

"I look on at what's happening in Westminster just now with a sense of utter despair on behalf of people across England and other parts of the UK as that vacuum of leadership both in the Tories and Labour develops," Sturgeon told the BBC.

She also suggested the Brexit vote could see the departure of Scotland, which voted to remain in the EU, in a second independence referendum which could lead to the collapse of United Kingdom.

Cameron has said he will stay on in his post until October to try to help reassure the public and markets, but his decision to announce his resignation immediately after the vote has unsettled those who campaigned to leave the European Union.

They say they will wait until a new eurosceptic leader is in place before triggering the process to leave the bloc as leading Conservatives jockey to take the mantle.

Former London mayor Boris Johnson, whose support for the leave camp galvanized the "Out" campaign, is favorite to replace Cameron but media have reported that there is a group of pro-Cameron lawmakers looking for "anyone but Boris".

Foreign Minister Philip Hammond ruled himself out of the contest, but said: "It's got to be somebody who can unite the Conservative Party ... but it's also got to be somebody with a credible strategy for dealing ... with the challenge of negotiating an exit from the European Union without destroying our prosperity in the process."

LABOUR DISARRAY

The deep divisions in Labour were also blown into the open when Corbyn sacked his foreign affairs policy chief, Hilary Benn, overnight because, as his spokesman said on Sunday, "he has lost confidence in him".

A growing number of Labour lawmakers have called on Corbyn to resign in the aftermath of the vote to leave the EU. Some party members say he failed to assuage concern among the party's traditional supporters; others that he should have campaigned more in favor of EU membership.

Two Labour politicians have submitted a motion of no confidence in Corbyn, which will be debated later this week.

Benn challenged Corbyn over his leadership, saying many lawmakers in the party had "no confidence in our ability to win the next election, which may come much sooner than expected".

Several members of Corbyn's 'shadow cabinet' - top policy chiefs who hold portfolios mirroring those of the government - resigned in protest at his leadership and others were set to follow.

But Corbyn, who was elected last year on a wave of enthusiasm for change among thousands of new, young Labour members, was "not going anywhere", said his finance spokesman, John McDonnell.

"I know how disappointed people are about the loss of the European referendum, but now is the time we hold together."

(Additional reporting by Estelle Shirbon; editing by Anna Willard)