LONDON -- Britain votes for a new Parliament and government Thursday after a campaign of three phases: the sleepy election, the surprising election and the security election.

What initially seemed the dullest campaign in memory has been transformed through unexpected missteps, surprise developments and deadly attacks that have pushed national security to the top of the agenda.

Why is there an election?

Why, oh why? That's the question many Britons asked when Prime Minister Theresa May announced on April 18 that she was calling a snap election, three years early. Voters went to the polls in a 2015 election, and in the June 2016 European Union membership referendum. The last thing many wanted was another divisive campaign.

But for May the time seemed right. She became prime minister through a Conservative Party leadership contest when predecessor David Cameron resigned after the referendum, and an early election would give her the chance to gain a personal mandate from voters.

Get Breaking News Delivered to Your Inbox

With polls suggesting a big Conservative lead, May looked likely to increase her majority in Parliament and strengthen her hand in Brexit negotiations with the EU.

Who are the contenders?

In the blue corner -- traditional color of the Conservative Party -- is May, a 60-year-old lawmaker known in her party as a quietly effective operator. A former advocate of remaining in the EU, she now promises to press forward with Brexit, taking Britain out of the bloc, reducing immigration and forging a new relationship with the U.K.'s European neighbors.

In the opposition red corner is the Labour Party's Jeremy Corbyn, a 68-year-old socialist who was elected leader by party members two years ago -- to the chagrin of many Labour lawmakers, who wanted a more centrist chief.

Jeremy Corbyn, Leader of the Labour Party, waves to supporters after speaking at a campaign rally at Union Chapel in Islington, June 7, 2017, in London. Getty

Critics say Corbyn, an advocate of nationalization and other old-left policies, embodies an outdated vision the party left behind during the "New Labour" years of Prime Minister Tony Blair. Supporters see him as a refreshingly authentic alternative to the pro-business, budget-cutting Conservatives.

Among smaller parties, the pro-independence Scottish National Party is seeking to repeat its 2015 near-sweep of seats in Scotland. The staunchly pro-EU Liberal Democrats hope to scoop up voters opposed to leaving the bloc. And the U.K. Independence Party -- instrumental in getting Britain to leave the EU -- hopes to regain a foothold in Parliament, after losing its sole lawmaker before the election.

What are the big issues?

Brexit, which had been expected to dominate the campaign, has played a surprisingly small role. Both Labour and the Conservatives say they will go through with the split, then seek the closest possible relationship with the EU. Neither party has provided many details of how this will be accomplished.

The election's early stages pointed toward the predicted coronation for May and the Conservatives, campaigning under the slogan "strong and stable government."

But it soon became clear that Corbyn's anti-austerity message was resonating with many voters, especially the young. Labour has successfully painted the election as a choice between two visions of society, promising to govern "for the many, not the few."

May's tightly controlled campaign style, which saw her speaking largely to hand-picked groups of supporters, began to grate. And then the party produced an election manifesto that gave ammunition to critics; a proposal to make pensioners pay for more of their long-term care costs was a plan dubbed a "dementia tax" by opponents.

May then made the disastrous move of backing down on the policy, seriously undermining her "strong and stable" mantra.

What role has terrorism played?

Two deadly attacks transformed the campaign, pushing terrorism and security to the top of the agenda.

The May 22 bombing at an Ariana Grande concert in Manchester killed 22 people and halted campaigning for several days. When it resumed, May was facing questions about her record as Britain's interior minister between 2010 and 2016 -- years in which police budgets were cut and the number of officers fell by almost 20,000.

After three attackers killed eight people in a vehicle and knife rampage around London Bridge on Saturday, May said "enough is enough" and vowed to clamp down on extremism, even if that means watering down human rights laws.

Opponents pointed out that May was in charge of police and the domestic security service when the Manchester and London attackers, all known to the authorities, slipped through the net.

Who is going to win?

When the campaign started, the Conservatives were as much as 20 points ahead in opinion polls. More recent surveys still point to victory for May -- but not necessarily the landslide she seeks.

The latest opinion polls vary between a solid Conservative lead and a dead heat, with projected outcomes ranging from a Conservative majority of more than 100 to a "hung Parliament," in which no party has a majority.

The difference depends largely on the predicted size of turnout among young people, traditionally the least likely to vote.

Polls are open from 7 a.m. until 10 p.m. (0600GMT to 2100GMT) on Thursday, and results should be known in the early hours of Friday.