A look at the history of elections in the United Kingdom.

The UK votes in a snap general election on Thursday.

The election comes as Britain prepares for delicate Brexit negotiations on leaving the European Union.

OPINION: UK general election – A Tory dystopia in the making

Security has also come to the forefront of campaigning as the UK has experienced three terror attacks in the past three months – including an attack at London Bridge on June 3 that left seven dead and dozens injured.

When campaigning for the June 8 election began last month, polls showed the Prime Minister Theresa May’s Conservatives to be 20 points ahead of Jeremy Corbyn’s Labour Party.

READ MORE: UK general election – Corbyn, Labour and the unknown

Many polls are suggesting that the gap has narrowed significantly since then, and elections in the UK have often produced surprises.

Al Jazeera takes a closer look at past UK elections – the victories, defeats, and upsets since 1945.