Prime Minister Theresa May called the vote in April, when opinion poll ratings for her and her centre-right Conservative party were sky-high, presenting herself as the strong leader to steer the country through tough negotiations to leave the EU.
Although pre-election polls suggest she will increase her majority, Islamist attacks in London and Manchester have put her under pressure, while campaign missteps have dented her reputation as a safe pair of hands.
An exit poll when voting stops at 10:00 pm (2100 GMT) will give an indication of the outcome, although the final picture will not begin to emerge until early Friday.
Opposition Labour leader Jeremy Corbyn, a socialist anti-war campaigner who only commands the confidence of a quarter of his own lawmakers, has run an energetic campaign, promising change and an end to austerity.
Security was heightened as millions cast their ballots in polling stations ranging from schools and public buildings to churches, pubs and even a windmill and a launderette.
Final pleas from leaders
"Together we can secure the best Brexit deal," May said Thursday on Twitter.
"Your vote will help secure a stronger economy and a brighter future for Britain," she said, sticking to campaign themes.
"If you believe in Britain and that our best days lie ahead, give me your backing to lead Britain."
Corbyn, a veteran socialist who has never held ministerial office and defied the odds to win the Labour leadership two years ago, pledged he would "lead a government you can rely on".
"We've left no place and no stone unturned to get the message out: that this country could be very different with a Labour government," he said.
"Rise like lions. We are many, they are few."
May and Corbyn both cast their votes in their respective constituencies of Maidenhead, southern England, and Islington, north London.
The Scottish nationalists were the third-biggest group in the outgoing parliament and are chasing a second independence referendum.
Scotland's First Minister Nicola Sturgeon, the party leader, pledged "strong voices standing up for Scotland, against Tory cuts".
Polling experts -- many of whom failed to predict the historic referendum vote to leave the European Union last year -- are somewhat wary of calling the outcome.
But predictions of her expected margin of victory vary widely, and one shock model even predicted May could lose her working majority of 17 in the 650-seat House of Commons.
A final pre-election projection published Thursday by pollster Michael Ashcroft predicted a Conservative majority of 76 seats, gaining ground as Labour and the Scottish nationalists slip back.
A final poll by YouGov on Wednesday put the Conservatives seven points ahead of Labour, while ICM gave May's party a 12-point lead over its rivals.
Such predictions stand in stark contrast to a Monday poll by Survation, which gave a narrow one-point gap.
While May toured target seats around the country, delivering slogan-heavy speeches in workplaces, Corbyn drew large crowds to open-air rallies.
May, 60, has presented herself as uniquely qualified for EU divorce talks starting on June 19 and said her 68-year-old rival would be "alone and naked in the negotiating chamber".
The London stock market and the pound slid on Thursday, with investors wary.
The FTSE 100 index, which initially rose and then eased back, ended the day with a loss of 0.4 percent. While the pound dipped, it was still holding on to gains made after May called the election.
Exhausted by government
It is the third time Britons have been called to vote since 2015, twice for a general election and once for the EU referendum, and voter fatigue appeared to be an issue for some.
"A lot of my family aren't voting, which I'm shocked at," said 20-year-old Alicia Milner in Halifax, northern England, saying they were "exhausted by the government".
The election is May's first since taking office after Britons voted by 52 percent to leave the EU after four decades of membership.
"I want another five years of stability, and a stronger hand in Brexit negotiations," said Dave, 29, in the London neighbourhood of Hackney.
"The main issue for me is getting along with Brexit," added Fabrizio, 42, in the wealthy London district of South Kensington.
Campaign affected by attacks
Campaigning was rocked by a suicide bombing at a Manchester concert on May 22, which killed 22 people, followed by Saturday's knife and van attack in central London, which left eight dead.
Campaigning was twice suspended in the aftermath of the attacks, which May blamed on "evil" Islamist ideology.
The Conservatives were damaged by a manifesto plan for elderly care that would see some pay more, while Labour also pounced on government spending cuts aimed at reducing the budget deficit.
But there was a little light relief after an ill-tempered campaign as thousands of voters brought their pooches to polling stations, posting their pictures on Twitter under the hashtag #dogsatpollingstations.
One voter near Reading in south-east England turned up to cast her ballot on her horse, Splash.