Get breaking news alerts and special reports. The news and stories that matter, delivered weekday mornings.

LONDON — Europe held its breath early Friday after Britons voted in a national referendum on whether or not to quit the European Union, with the outcome on a knife-edge after a bitterly divisive campaign.

The polls closed at 10 p.m. Thursday local time (5 p.m. ET). A record-setting 46.5 million people in the U.K. registered to cast their ballot over what has been dubbed the "Brexit" question — with 71 percent turning out to vote.

By 3:55 a.m. local time Friday (10:55 p.m. ET Thursday), NBC News' partner ITV News put the "Leave" campaign — which favors withdrawal from the EU — ahead.

With around 17.5 million ballots counted, "Leave" was at 51.3 percent and "Remain" at 48.7 percent. However, 161 of the U.K.'s 382 local centers had yet to report and millions of votes remained uncounted.

Supporters of the "Stronger In" Campaign react as results of the EU referendum are announced in London early Friday. ROB STOTHARD / AFP - Getty Images

Opinion polls before the historic vote suggested the "Leave" campaign was virtually tied with those urging voters to "Remain" in the 28-country trading bloc.

U.K. Independence Party leader Nigel Farage, a key figure in the "Leave" campaign, was upbeat early Friday. He tweeted: "I now dare to dream that the dawn is coming up on an independent United Kingdom."

Let our news meet your inbox. The news and stories that matters, delivered weekday mornings. This site is protected by recaptcha

In an subsequent press conference, Farage added: "If the predictions now are right, this will be a victory for real people ... Let June 23 go down in our history as our independence day."

Financial markets were keenly awaiting an outcome after months of uncertainty.

With as many as 12 percent of voters undecided, "Remain" campaigners earlier handed out leaflets near London Underground stations on Thursday in the hope of winning last-minute votes.

Among them was Dutchman Marc Bolland, the former CEO of Britain’s iconic Marks & Spencer chain of department stores.

“I am doing this as an individual because I think it is important,” he told NBC News. “This is a decision that will affect us for the next 50 years."

Voters in the central London district of Clerkenwell echoed the prediction of pollsters that the outcome would be close.

“I think it will be very, very tight — a lot closer than people think,” said Michael Roman, 54, a construction engineer from Kent in southeastern England.

Thank you everyone who voted to keep Britain stronger, safer & better off in Europe - and thousands of @StrongerIn campaigners around the UK — David Cameron (@David_Cameron) June 23, 2016

Mary Brookes, 51, a teacher and local resident wearing a "Remain" button, said: “I hope people will see sense and keep us in the EU. It is far too important to throw away because of temporary problems.”

Others were just happy that the campaign was finally coming to an end.

“I feel better now it is over,” said Jojo Lands, a nurse aged in her 40s. “It is on television, Facebook, everywhere. I don’t want to talk about it again.”

The final week of campaigning included a bruising televised debate and a personal appeal by Prime Minister David Cameron from the steps of 10 Downing Street — and was overshadowed by last week's murder of pro-EU lawmaker Jo Cox.

In the House of Commons on Monday, members of parliament broke off from campaigning to pay emotional tributes to the mother-of-two. However, it was not clear if the tragedy would affect the result.

Farage had been criticized for emotive campaign posters blaming the EU for levels of immigration and criticizing its handling of the migrant crisis.

"Win or lose this battle tonight, we will win this war" said UKIP leader Nigel Farage #EURef https://t.co/uk5OptH1Sthttps://t.co/oNIFhwTnjV — ITV News (@itvnews) June 23, 2016

Ballot papers will be counted at 382 local centers across Britain and Northern Ireland, with the results relayed to 12 regional centers that will also declare the totals for each side.

The first of the local results started coming in shortly after midnight early Friday (around 7 p.m. Thursday ET) and the final result — not expected until later Friday — will be declared by the chief counting officer in Manchester, northern England.

Analysts were divided about what a high or low turnout would mean for either side. John Curtice, a polling expert and professor of politics at the University of Strathclyde, believes a low turnout would benefit the "Leave" side because "Remain" voters are less motivated.

However, Justin Fisher, professor of politics at Brunel University, told Bloomberg that supporters of Brexit were generally less politically-engaged and less likely to vote. "If 'Leave' manage to mobilize them, then a high turnout may not be good for 'Remain,'" he said.