A bill to give 16 and 17-year-olds the right to vote in the Scottish independence referendum was passed by MSPs on the last day of their term.

The legislation had the backing of the SNP, Labour and Liberal Democrats.

It gives those born on or before 18 September 1998 the right to vote in the referendum.

But a proposal supported by the Lib Dems and Greens to give prisoners serving short term sentences the right to cast their vote failed.

Reducing the voting age has been a long standing policy of the SNP, which forms the Scottish government.

The party said it had been backed by organisations including Scotland's biggest teaching union, the EIS, as well as the Scottish TUC, National Union of Students and the Electoral Reform Society.

Biggest stake

The UK government previously opposed votes for 16 and 17-year-olds in the independence referendum, although the measure was eventually included in the Edinburgh Agreement, which set out the terms for the vote and was signed by both Westminster and Scottish ministers.

Announcing the measure as part of the The Scottish Referendum (Franchise) Bill earlier this year, Deputy First Minister Nicola Sturgeon said young people had the biggest stake in the future of the country.

The Conservatives oppose extending the franchise to 16 and 17-year-olds, with the party's former Scottish leader Annabel Goldie previously saying young people would only have a "very restricted" opportunity to test their knowledge and opinions against life experience.

The franchise bill will base voter eligibility on Scottish parliamentary and council elections.

That means groups of people entitled to vote include people living in Scotland who are British, Irish or from other EU countries, "qualifying Commonwealth citizens" and members of the armed services serving overseas who are registered to vote in Scotland.

But a controversial proposal to give prisoners serving short sentences the right to vote failed after being dismissed by the Scottish government, with Ms Sturgeon saying those who commit a crime serious enough to be denied their freedom should also be denied the right to vote.