The sum was about £2.1m more than had been estimated ahead of the vote.
Deputy First Minister John Swinney said the additional expenditure was due to the very high turnout.
A total of 3,619,915 people - 84.5% of the electorate - voted on 18 September. Voters backed Scotland staying a part of the UK by 55% to 45%.
Mr Swinney confirmed the Scottish government's final bill for running the poll in an answer to a parliamentary question.
The total of £15.841m included almost £10.9m which was spent on providing counting officers across Scotland to tally up the votes in each council area.
The chief counting officer's costs for administering the ballot amounted to just under £510,000, mainly reflecting the expenses associated with holding the "international event to declare the referendum result" at Ingliston on the outskirts of Edinburgh.
In his answer, Mr Swinney described the referendum as a "triumph for democracy and participation, with the highest turnout of any UK ballot for over a century".
He added: "In anticipation of a high turnout, the chief counting officer provided guidance to counting officers on issues such as printing additional ballot papers, to ensure that replacement ballot papers were available to cover for any damaged or misprinted ballot papers, and limiting the number of electors attending individual polling stations, to avoid queues.
"In addition, additional staff were employed at count centres in order to ensure a prompt result. These, and other similar sensible contingency measures, added to counting officers' costs but ensured that the poll ran smoothly on the day."
Scottish Conservative chief whip John Lamont said: "Everyone accepts the independence referendum was a historical constitutional event and, therefore, will have had cost implications.
"But the fact remains the SNP said the eventual bill for the taxpayer was going to be much lower. Many voters will feel this was a lot of money to spend for the nationalists to be told that most people prefer Scotland to remain in the UK."
The cost of staging last year's Scottish independence referendum amounted to just over £15.8m, it has been revealed.