A vast majority of the first councils to declare showed voters rejecting independence.

Earlier, pollster YouGov had predicted that No had won the campaign with 54% of the vote, a figure broadly in line with the national total as councils announced results.

The prediction was followed by wins for No in the first four councils to declare, albeit relatively small ones whose impact on the final vote will be limited: Clackmannanshire, Orkney, Shetland, and the Western Isles.

Two other urban areas also went No - Inverclyde and Renfrewshire - before the Yes camp secured its first success in Dundee, which had been tipped as the city in Scotland most likely to back independence.

West Dunbartonshire then followed suit for Yes, but Midlothian, East Lothian, Stirling and Falkirk went No, and there was a devastating loss for Yes in Angus, an SNP heartland, followed soon afterwards by No successes in Aberdeen, Dumfries and Galloway and East Renfrewshire.

Yes were rallied briefly by a narrow win in North Lanarkshire, but lost heavily in South Lanarkshire and East Dunbartonshire, and then by a sizeable margin in Perth & Kinross, the base of Finance Secretary John Swinney.

West Lothian, which covers Linlithgow, birthplace of Alex Salmond, also went No.

There was better news for Deputy First Minister Nicola Sturgeon, on hand to hear Yes triumph by around 25,000 votes in Glasgow.

But No hit back with four more victories, in the Borders, and North, South and East Ayrshire, and then added Aberdeenshire and Edinburgh. The margin in the capital was particularly emphatic: with 194,638 No votes against 123,927 for Yes.

In the first poll published after the ballot closed, Yougov based its prediction on the responses of 1828 people after they voted today, together with those of 800 people who had already voted by post.

Today's respondents had previously given their voting intention earlier this week. By recontacting them, YouGov said it could assess any last-minute shift in views. Today's responses indicate that there has been a small shift on the day from Yes to No, and also that No supporters were slightly more likely to turn out to vote.

YouGov also asked people whether they had encountered active supporters of the Yes and No campaigns at their local polling station and, if so, whether the campaigners had acted reasonably.

Big majorities said that any campaigners they encountered behaved reasonably; but 10% of No voters said they had encountered unreasonable behaviour by Yes campaigners, while 5% of Yes voters said they encountered unreasonable behaviour by No campaigners.

YouGov president Peter Kellner said he was 99% certain that Scotland would vote to remain in the UK.

He told Sky News: ''At the obvious risk of looking like a complete prat in eight hours' time, I would say it is a 99% certainty of a No victory... I can't see no losing this now.''

Mr Kellner said today's research had suggested ''substantially more'' people switched from Yes to No than the other way around.

He added: "'If we have got this wrong, if Yes win, we and by extension other pollsters, have got something badly wrong."

Chief Secretary to the Treasury Danny Alexander told Sky News: "It does look like we have secured a No vote and that is clearly very welcome.

"It is also important to say a No vote is a mandate for change in Scotland, it's a mandate for the strong proposals on more powers for the Scottish Parliament we have been setting out in this campaign."

Mr Alexander, the second most senior Liberal Democrat minister in the coalition, warned that he did not want to pre-judge the results.

Liberal Democrat Deputy Prime Minister Nick Clegg said in a tweet: "The people of Scotland have cast their votes. I sincerely hope that they remain a part of our family of nations."

Scottish Conservative leader Ruth Davidson told the BBC she is quietly confident that the "silent majority" of Scots would give a victory to No.

She said: "I think we have a confidence, a quiet confidence, that the quiet majority of Scots have spoken."

Ms Davidson said whatever the result, politics in Scotland would change, with the promise of more powers for Holyrood in the event of a No vote made by all three of the main parties.

"The status quo has been thoroughly smashed, whether it is a Yes vote or a No vote Scotland is going to change after this," she said.

"The question is does it change within the United Kingdom or does it change out with the United Kingdom."

The Tory MSP said the referendum campaign had been an "almost wholly positive experience", adding: "We've had the biggest, broadest, most open conversation amongst the people of our country on any single issue and it's a conversation that I think we needed to have."

The chairman of Yes Scotland Dennis Canavan said it was "probably correct" that today's vote would settle the independence question for a lifetime.

He said that while the Yes camp had fought a "very positive campaign, a magnificent campaign", the No message was characterised by "a bit of negative scaremongering going on, a bit of collaboration, perhaps even collusion, on the part of the British establishment".

Michelle Thomson, managing director of the pro-independence Business for Scotland campaign, said the Yes campaign would respect the result of the ballot, even if it meant continued membership of the UK.

Ms Thomson told Sky News: "This is all about the settled will of the sovereign people of Scotland, and if that is what they express, then of course the wider Yes campaign will accept that. That's the whole point.

"Really, then the emphasis will be on Westminster to make good the promises they've made within the timetable they have set out.

"Certainly Scotland will move forward together, there will be a tomorrow, we will continue to be the best of friends."

Liberal Democrat MP for Gordon and No supporter Sir Malcolm Bruce said he believed that "reality has kicked in" with voters switching back to No after being briefly seduced by the Yes campaign's message.

Sir Malcolm said: "Certainly we felt that the campaign was swinging back to our side - if it ever really swung away to the extent that people suggested - both in terms of our canvassing and the responses we've been getting as people came out of the polling stations.

"I will be very well satisfied if the campaign to keep Scotland in the UK has succeeded. I believe it's in the best interests of Scotland and the UK that that should happen.

"I think the agenda put forward by the Yes campaign is scary. To suggest we build a new state with no bank, no reserves, no currency and no visible means of financial support, in my view was totally irresponsible, but it was very plausible, it was very attractive to people who wanted to believe it. They were drawn into it by this positivity, but in the end reality I think has kicked in."

Regardless of the eventual outcome, Scotland is on course to break all UK electoral voting records. Labour campaign sources predicted a turnout of 84-85%, based on feedback from polling stations across the country.

The previous highest turnout in any UK election was 83.9% in the 1950 general election. Turnout at the last Holyrood election in 2011 just scraped above 50%.

The highest turnouts so far declared came in East Dunbartonshire (91%) and East Renfrewshire (90.4%). The lowest reported turnout has been Glasgow with only 75% of the electorate coming out to vote. Dundee had the second lowest rate of 78.8%.

As counting of votes began, Nicola Sturgeon hailed the ballot as "an amazing, emotional, inspirational day of democracy".

Labour's leader in Scotland Johann Lamont said that voters north of the border had cast "the most important votes of our lives".

Ms Lamont said: "Today the people of Scotland have cast the most important votes of our lives. Thank you to everyone who has worked for a No today."

And Ms Sturgeon tweeted: "So that's that. Polls have closed. What an amazing, emotional, inspirational day of democracy this has been. Now we wait."

Blair McDougall, the Better Together campaign director, said: "I think there has been an extraordinary turnout tonight - near 100% turnout in some places.

"I think it's great for Scottish democracy, it could be great for Scotland. I think there will be a strong No vote and I think it will mean a better future for people in Scotland.

"There has been the biggest super-poll in Scottish political history today with probably the biggest turnout in recent political history."