On Thursday people across the UK will head to their local polling station to vote in the general election.
Polling will take place between 07:00 and 22:00 GMT. But how long will it be before we know who's won, and what the next government could look like?
The exit poll
As soon as voting closes, the results of an exit poll are announced.
This is a joint poll for the BBC, ITV News and Sky News, carried out by polling company Ipsos Mori.
Voters are asked to fill in a mock ballot paper as they leave the polling station, indicating how they have just voted.
The results of this poll, conducted at 144 polling stations, are used to predict how many seats each party has won, and who might form a government.
It will also allow BBC analysts to forecast approximately how many seats each party has won.
The exit poll has proved to be very accurate in recent years. In 2017 it correctly predicted a hung Parliament, and in 2015 it predicted a Conservative majority.
The first results usually come in about an hour after the close of the polls.
There are 650 constituencies in the UK. The candidate with the most votes in each one becomes a Member of Parliament (MP) in the House of Commons.
To win, they simply need more votes than anyone they are standing against.
Houghton and Sunderland South currently holds the record for being the quickest constituency to return a result (22:48 BST in 2015). But in 2017 it was nine minutes behind Newcastle Central, where a winner was announced at 23:01 BST.
The rest of the results are declared throughout the night and into the next day. Most counts will be completed by 06:00 GMT.
When will we know who's won?
If a party wins in 326 constituencies - that's just over half the number of seats in the Commons - it will have gained a majority.
In practice, slightly fewer seats are needed. That's because the Speaker of the House, who is usually a Conservative or Labour MP (currently Labour's Sir Lindsay Hoyle), remains neutral.
Sinn Fein MPs also have a long-standing tradition of not taking their seats.
If a party has a majority, its leader will head to Buckingham Palace to ask the Queen's permission to form a new government.
What if nobody wins outright?
If no party wins an outright majority, there will be what is known as a hung Parliament.
If this happens, the prime minister in power before the general election will stay in office and be given the first chance to form a government.
One option for the prime minister would be to form a partnership with another party as a coalition government.
The two parties will decide behind closed doors who will be given the most important roles and on which policies they might compromise.
Alternatively, they could establish a minority government, where they don't have a majority in the Commons but govern anyway.
Confidence and supply agreement
A minority government can take charge with a confidence and supply agreement, where it asks for occasional help from another party. That party might agree to back the government on important votes. In exchange, the government guarantees it influence over things it cares about.
If the previous prime minister fails to form either a coalition or an agreement with another party, they are usually expected to resign. They will recommend that the leader of the largest opposition party gets the chance to form a government.
If the opposition party also fails, then Parliament will be dissolved again and there will be another election.
How will we know how many people voted?
Turnout is the number of people who vote in an election as a proportion of all the people who were eligible to vote.
On election night, the BBC calculates the percentage turnout by dividing the number of valid votes cast for all candidates by the number of people who could vote (known as the electorate).
Spoilt or rejected ballots are not included.
The UK and individual nations' turnout figures are updated through the night, based on the constituencies declared so far.
Where can I find the results?
The BBC News website will feature a full breakdown of the results across the UK.
Results will appear as they are announced on an interactive map and postcode search.
Readers can also follow the latest developments in their own constituencies on BBC live pages and scoreboards.
On social media, @BBCElection will tweet out every constituency result.
Huw Edwards will be the lead presenter of BBC One's election night special, while Jim Naughtie and Emma Barnett will host live election night coverage on BBC Radio 4 through until Friday morning.