Media playback is unsupported on your device Media caption Theresa May says she'll "reflect on what we need to do to take the party forward"

Theresa May has said she will put together a government with the support of the Democratic Unionists to guide the UK through crucial Brexit talks.

Speaking after visiting Buckingham Palace, she said only her party had the "legitimacy" to govern, despite falling eight seats short of a majority.

Later, she said she "obviously wanted a different result" and felt "sorry" for colleagues who lost their seats.

But Labour said they were the "real winners".

The Lib Dems said Mrs May should be "ashamed" of carrying on.

The Tories needed 326 seats to win another majority but they fell short and must rely on the DUP to continue to rule.

In a short statement outside Downing Street after an audience with the Queen, Mrs May said she would join with her DUP "friends" to "get to work" on Brexit.

Referring to the "strong relationship" she had with the DUP but giving little detail of how their arrangement might work, she said she intended to form a government which could "provide certainty and lead Britain forward at this critical time for our country".

"Our two parties have enjoyed a strong relationship over many years," she said.

"And this gives me the confidence to believe that we will be able to work together in the interests of the whole United Kingdom."

It is thought Mrs May will seek some kind of informal arrangement with the DUP that could see it "lend" its support to the Tories on a vote-by-vote basis, known as "confidence and supply".

Image copyright PA Image caption The PM earlier visited Buckingham Palace

Later, she told reporters that she had "wanted to achieve a larger majority but that was not the result".

"I'm sorry for all those candidates... who weren't successful, and also particularly sorry for MPs and ministers who'd contributed so much to our country, and who lost their seats and didn't deserve to lose their seats.

"As I reflect on the results, I will reflect on what I need to do in the future to take the party forward."

Media playback is unsupported on your device Media caption "The union is our guiding star" - DUP's Arlene Foster

DUP leader Arlene Foster confirmed that she had spoken to Mrs May and that they would speak further to "explore how it may be possible to bring stability to this nation at this time of great challenge".

While always striving for the "best deal" for Northern Ireland and its people, she said her party would always have the best interests of the UK at heart.

Scottish Conservative leader Ruth Davidson has since sought assurances from Mrs May that any deal with the DUP will not affect LGBTI rights across the UK. Northern Ireland is the only part of the UK where same-sex marriage is not legal.

A source close to Ms Davidson, who is gay, told the BBC: "The PM needs to remember there are more Scottish Conservatives than DUP MPs."

Who are the DUP?

The DUP are pro-union (not Europe but UK), pro-Brexit and socially conservative.

The party, which returned 10 MPs to Westminster, has garnered a reputation for its strong, sometimes controversial views.

It opposes same-sex marriage and is anti-abortion - abortion remains illegal in Northern Ireland, except in specific medical cases.

One MP is a devout climate change denier, while a former MP once called for creationism - the belief that human life did not evolve over millions of years but was created by God - to be taught alongside evolution in science classes.

During the election campaign, the DUP's Emma Little-Pengelly was endorsed by the three biggest loyalist paramilitary organisations.

Read more about the DUP here and meet their MPs here.

Who's in the Cabinet?

Image copyright PA

In an ongoing Cabinet reshuffle, five cabinet ministers are certain to stay: Defence Secretary Sir Michael Fallon; Brexit Secretary David Davis; Home Secretary Amber Rudd; Chancellor Philip Hammond and Foreign Secretary Boris Johnson.

Mr Hammond said, in a tweet, that he was "pleased to be reappointed so we can now get on and negotiate a Brexit deal that supports British jobs, business and prosperity". Mr Johnson tweeted that he was "delighted", adding "lots of great work to do for greatest country on earth".

However, those rarely seen on the campaign trail, including Andrea Leadsom, Priti Patel and Liam Fox, could be out, says BBC political correspondent Eleanor Garnier.

Comebacks from Iain Duncan Smith, Michael Gove and prominent leave campaigner Dominic Raab were being floated, she adds.

Where does this leave Labour?

Media playback is unsupported on your device Media caption Jeremy Corbyn: An "incredible result" for the Labour party

Labour leader Jeremy Corbyn has denounced Mrs May's plan to head up a minority government, calling for her to "make way" for a government that would be "truly representative of the people of this country".

He said Labour was ready to form a minority government of its own, after far exceeding expectations by picking up 30 seats in England, Wales and Scotland.

But even if it joined together in a so-called progressive alliance with the SNP, Lib Dems, Green Party and Plaid Cymru, it would only reach 314 seats - short of the 326 figure needed.

"We are ready to serve the people who have put their trust in us," he said, while stressing he would not enter into any "pacts or deals" with other parties.

Former Labour cabinet minister Lord Mandelson said the "surprise" result was a political "earthquake", and he'd been "wrong" to criticise Mr Corbyn's leadership of the party.

There are three posts that Mr Corbyn now needs to fill in the shadow cabinet, but sources say an announcement is not likely until Sunday at the earliest.

Streatham MP Chuka Umunna, a leading figure on the right of the party, has said he would accept a role in the shadow cabinet.

What about Scotland?

Media playback is unsupported on your device Media caption Nicola Sturgeon says the SNP 'will listen to voters'

The SNP remains the largest party in Scotland but lost 21 seats to the Tories, Labour and the Lib Dems.

Leading figures in the party such as Alex Salmond and Angus Robertson were defeated.

First Minister Nicola Sturgeon said her party's plans for a second independence referendum were "undoubtedly" a factor in the results, and she would "reflect carefully".

Ruth Davidson - whose Scottish Conservatives went from one seat to 13 - said Ms Sturgeon should now take a second referendum "off the table".

Read more here.

How did the parties fare?

The BBC's Laura Kuenssberg said the PM has returned to No 10 a "diminished figure", having ended up with 13 fewer seats than when she called the election in April.

She had called the election with the stated reason that it would strengthen her hand in negotiations for the UK to leave the EU - the talks are due to start on 19 June.

But the Tories are on 318 seats, ahead of Labour on 262 following its late win in Kensington, the SNP 35 and the Lib Dems on 12. The DUP won 10 seats.

As it stands, the Tories and the DUP would have 328 MPs in the Commons, giving it a wafer-thin majority although as Sinn Fein will not be taking its seven seats, the new administration will have slightly more room for manoeuvre.

Reaction to Theresa May's performance

Image copyright AFP Image caption Staff applaud Mrs May and her husband, Philip, in 10 Downing Street. Outside protesters gathered, waving placards condemning a Conservative-DUP government

After losing her majority, Mr Corbyn called on the prime minister to quit and Lib Dem leader Tim Farron said she should resign "if she has an ounce of self-respect".

Some in her own party have also called for her resignation, with Anna Soubry saying she should consider her position after a "disastrous" campaign.

However, other MPs have urged her to stay on - Iain Duncan Smith said a leadership contest would be a "catastrophe".

Tory MP Philip Davies said his party had made "a pig's ear" of the campaign, and fellow Tory MP Nigel Evans said his party had "shot ourselves in the head".

Mrs May's former director of communications, Katie Perrior, said the party should never have run a Presidential-style campaign when the leader is "shy" and doesn't like doing interviews.

The Green Party, which held its one seat at the election but saw its total vote halve, said a Conservative government propped up by the DUP would be a "coalition of chaos".

"The DUP, I don't think, are the kind of people you want calling the shots," co-leader Jonathan Bartley said.

Downing Street said Mrs May received congratulatory calls from French President Emmanuel Macron, who said he was pleased that she would continue to be a close partner, and US President Donald Trump, who agreed with her that they looked forward to close co-operation.

Where does this leave Brexit and the Conservative manifesto?

Britain's exit from the European Union has been plunged into uncertainty, says BBC diplomatic correspondent James Landale.

The government - and the DUP - may have to rethink their strategy, and the EU will be dismayed to be facing a divided British parliament in a divided Britain, he adds.

European Council president Donald Tusk says there is now "no time to lose" over Brexit and the European Parliament's chief negotiator, Guy Verhofstadt, said the result was an "own goal" which made negotiations more "complicated".

Read more from James here

BBC analysts says the Conservative's election manifesto may also be in jeopardy.

Policies, such as new grammar schools and social care reforms, are likely to get ditched, they say. Without a majority in the Commons, members of the Lords might feel entitled to block them.

Also, within the Conservative party, there is a widespread perception that the manifesto was a disaster which they need to distance themselves from, they add.

Other big shocks and surprises

In a night of high drama, former Lib Dem leader Nick Clegg lost his seat while current leader Tim Farron clung on by less than 800 votes in his Cumbrian constituency.

Vince Cable and Jo Swinson are among the Lib Dems returning to the Commons after winning back their former seats.

Media playback is unsupported on your device Media caption UKIP's Paul Nuttall: "I am standing down with immediate effect"

UKIP leader Paul Nuttall quit after his party failed to win any seats and saw its vote collapse across the country. Former party chairman Steve Crowther will lead the party on an interim basis.

Gerry Adams, president of Sinn Fein, which gained three seats taking its total to seven, said it had been a "very good election for republicanism", and appealed for "calm reflection" on how to go forward.

In more results from the night:

Tory Zac Goldsmith regained his Richmond Park seat after two recounts

Labour's Dianne Abbott won a huge majority of 35,139 in Hackney North and Stoke Newington

Home Secretary Amber Rudd narrowly held her seat with a majority of just 346