EDINBURGH—Scottish voters rejected a heated bid for independence, providing a narrow escape for a British government that scrambled to dole out promises of new local powers for Edinburgh to head off the breakup of a 307-year-old union.

Scottish First Minister Alex Salmond said early Friday he had accepted that the majority of Scottish voters had decided not to become an independent country.

The tally at around 6:30 a.m. local time, which included results from 31 of the 32 districts in Scotland, showed 55% of voters rejecting the independence question and 45% favoring it. About 3.5 million votes had been counted. More than four million people were registered to vote in the election.

Mr. Salmond said the fact that around 1.6 million people voted to exit the union was a victory in itself. "I don't think of any of us…would have thought such a thing could be credible or possible," he said.

While the pro-independence camp won expected victories in places like Glasgow and Dundee, the U.K. government's late press to pull out a victory appeared to help avert a major embarrassment. The outcome is a relief for British Prime Minister David Cameron, who agreed to the referendum in a deal two years ago with Mr. Salmond, then watched as a double-digit lead dissolved to a dead heat on the back of relentless campaigning by Mr. Salmond and the pro-independence campaign.