Media playback is unsupported on your device Media caption The question of Scottish independence dominates the last televised debate between the leaders of Holyrood's main political parties

The prospect of a second referendum on Scottish independence has dominated the final TV debate between the leaders of the country's five main parties.

SNP leader Nicola Sturgeon and Patrick Harvie of the Scottish Greens argued it would be undemocratic to rule out a referendum if enough people wanted one.

But the leaders of the other three parties called on them to respect the result of the last referendum.

The BBC Scotland debate was held at Hopetoun House, near Edinburgh.

It featured Ms Sturgeon and Mr Harvie alongside Scottish Labour leader Kezia Dugdale, Scottish Conservative leader Ruth Davidson and Liberal Democrat leader Willie Rennie.

The hour-long discussion was held just days before Thursday's Scottish Parliament election.

There were angry exchanges over delays to the UK government contracts to build Royal Navy frigates at the Clyde shipyards, which unions have claimed could cost hundreds of jobs.

But it was the issue of independence - and more specifically whether or not there should be a second referendum in the future - that sparked the fiercest responses.

What do the parties' manifestos say?

Image caption The debate was held at Hopetoun House in South Queensferry

Ms Sturgeon stuck to her position that there should be another referendum if it was clear a majority of people wanted one, or if there was a "material change" in circumstances, such as Scotland being taken out of the EU against its will.

The SNP leader said she continued to believe that independence offered the best future for the country.

'Sustained evidence'

She added: "But if those of us in Scotland who support independence cannot persuade people that we didn't persuade in 2014, if independence doesn't become the preferred option of a majority, we will not have earned the right to ask that question again.

"But on the other hand, if people do change their minds and there is clear and sustained evidence that independence has become the preference of a majority of people in Scotland, then no politician has the right to stand in the way of the democratic wishes of the Scottish people."

Speaking later, on BBC Radio 4's Today programme, she clarified that opinion polls held over a period of time would be the deciding factor in calling a second referendum.

She reiterated that there would need to be "clear and sustained evidence".

"We would have to see, in a range of polls over a period of time, that independence had become the preferred option of the majority," she said.

Ahead of the debate, Ms Sturgeon told the Sunday Herald newspaper that she was confident that a second referendum would be held while she is first minister.

Scottish Labour leader Kezia Dugdale pointed out that Ms Sturgeon had previously described the first referendum as being "once in a lifetime" and "once in a generation", and accused her of "trying to pull the wool over people's eyes" on the issue.

Image copyright PA Image caption Nicola Sturgeon and Patrick Harvie want to see a second referendum on independence in the future

Ms Dugdale said the SNP manifesto for the election mentioned independence on page 24, and claimed the SNP "took 210 words to say 'mibbes if, mibbes aye, mibbes no, I'm not sure, trust me or ask the pollsters'."

She added: "So many people in Scotland just want to move on from that referendum of the past. We have substantial new tax and welfare powers coming to the Scottish Parliament.

"Wouldn't it be great if we just used them to talk about the future and how we will improve our schools, our NHS, create opportunities for young people and build the Scotland that we all want to see".

Analysis by Philip Sim, BBC Scotland political reporter

Image copyright PA

With just days to go until the Holyrood election on Thursday, the party leaders put on a feisty performance in a last-ditch bid to win over voters.

The noisiest exchanges came between Nicola Sturgeon, Kezia Dugdale and Ruth Davidson, who cut across each other to fling barbs about shipyards, independence and healthcare.

Patrick Harvie and Willie Rennie at times found themselves on the periphery of the debate as well as the stage, with the female leaders relatively happy to leave them to speak, concentrating their fire on each other.

And while the women scored plenty of points of their own on each other, this approach allowed both men space for a shot at goal - with Mr Rennie scoring perhaps the biggest cheer of the night by calling for people to move on from the independence debate.

Yes or No, he argued, we should be looking to unite and govern Scotland properly for the next five years.

While there was the usual warm reception for constitutional arguments, the debate audience seemed equally fired up about public policy and social issues and seemed to head home thoroughly pleased by their evening.

There will be little respite for the five party leaders though - they face three more days of frantic campaigning until Scotland goes to the polls.

Scottish Conservative leader Ruth Davidson said Ms Sturgeon had responsibilities to "all of Scotland, not just to the SNP" in her role as first minister.

Ms Davidson said: "Her responsibilities mean that she shouldn't be keeping this wound open - it is not good for our country, it is not good for our economy, it is not good for encouraging jobs and growth and all of the things that we want to see.

"Before the referendum she went round every TV studio she could find and looked down the camera lens and told every person in Scotland that it was once in a generation, once in a lifetime.

"She has gone back on both of these promises - it is not good enough and it is not up to her to see one opinion poll she likes and say we're putting this country through it once more".

Image copyright PA Image caption Willie Rennie, Kezia Dugdale and Ruth Davidson all believe it is time to move on from the independence debate

Her views were echoed by Scottish Liberal Democrat leader Willie Rennie, who said the next five years should be used to focus on areas such as education, mental health and climate change targets.

Mr Rennie claimed that these area had all been neglected by the SNP government in the previous five years as it focused on trying to secure independence.

And he suggested the SNP was being "anti-democratic" by continuing to argue for independence.

'Groundhog day'

Mr Rennie added: "I want to focus on making Scotland one of the best countries in the world again. We will not achieve that by having a groundhog day debate about independence. If we keep on disrespecting the result, we will not achieve that better Scotland."

Patrick Harvie of the Scottish Greens said it was important to respect the result of the last referendum, but that it was also important to respect the fact that many people in Scotland voted in favour if independence.

He said it was not reasonable to expect independence supporters to simply "crawl away and shut up about it", and said the "great mass of people" in Scotland were capable of having a mature debate on the issue.

Image copyright BAE Systems Image caption Eight Type-26 frigates are due to be built at the Govan and Scotstoun yards on the Clyde

During the debate, which was chaired by the BBC's Sarah Smith and broadcast live on BBC One Scotland and the BBC news website, questions were put to the politicians by an audience of voters on topics including health, jobs and the Edinburgh schools fiasco.

The leaders also clashed about the future of the NHS and the shipyards on Glasgow's River Clyde, after union leaders there raised fears that a contract for the yards to build new Type 26 frigates for the Navy has been delayed.

Ms Davidson said UK government ministers had "categorically assured" her that the work would go ahead.

But Ms Sturgeon hit out: "The shipyards expected to start cutting steel now. They now believe they will not start cutting steel until December 2017. There has been a delay of a year-and-a-half and it is an absolute betrayal."

Prescription charges

And Ms Dugdale accused her Conservative rival of "having told a porkie" when she said there was no change to the Ministry of Defence order.

Ms Davidson also faced questions over her party's plans for the NHS, after the Scottish Conservatives said they would reintroduce prescription charges north of the border, claiming this would bring in £65m for the NHS each year.

The Tory leader said her party was "looking at increasing GP services" claiming the proportion of the NHS budget spent on primary care has been cut by the SNP.

But Mr Harvie challenged her, saying: "If we went down Ruth's line what would be next, charges to visit your GP?"

It was the third and final televised leaders' debate before the election, with BBC Scotland and STV having held one each earlier in the campaign.