There is a "possibility" that Scotland could stay both in the UK and the European Union, Kezia Dugdale has said.

Speaking in Edinburgh's Grassmarket on Thursday, the Scottish Labour leader added that First Minister Nicola Sturgeon should play a role in the UK's Brexit negotiations.

She said Scotland could only negotiate with the EU as part of the UK's team.

The Scottish Government responded that it was committed to being involved in "any negotiations about the next stages".

Meanwhile, the Scottish Greens accused Labour of having "abandoned its open-mindedness" on Scotland's constitutional future.

Dugdale also accused Scottish politicians of failing to reach out to Leave voters.

In what was her first major speech since the UK's vote to leave the European Union, she criticised her own party for failing to give a "full-throated defence on immigration".

Scapegoating migrants is an example of "giving simple answers to complex problems", the Labour leader said, adding it was "part of the reason we have got to where we are today".

In a Q&A following the speech, the Labour leader said "potential avenues" were being explored whereby Scotland may be able to stay in both the UK and the EU in a "federalist solution".

Dugdale said: "There's no question that the United Kingdom as one entity is going through a process for Brexit just now.

"But what I am arguing for is there may be a possibility that Scotland could retain its place both in the UK and in the EU through a potential - and I have to say this tentatively - a potential federalist solution which could see us achieve that.

"It's important I focus on that and I explore those options, because actually that's what the vast majority of people in Scotland want - that's been reflected in two referendum results."

Former Labour justice secretary Lord Falconer is said to be consulting with constitutional lawyers on such an option, known as the "reverse-Greenland" option.

Denmark is in a political union with the Faroe Islands and Greenland - but the latter two are not members of the European Union, while Denmark is.

The Scottish Labour leader said in her speech she had written to the UK government to demand that the Scottish First Minister feature in official Brexit negotiations.

But she claimed that Nicola Sturgeon would be unable to negotiate with the EU on Scotland's behalf unless she was part of the UK's top team.

She said: "Nicola Sturgeon needs to play a part of the UK's negotiating team, along with (London mayor) Sadiq Khan, Carwyn Jones and Arlene Foster (the Welsh and Northern Irish First Ministers)."

Dugdale went on: "These negotiations cannot be a Westminster Tory show. They need to represent all parties of government across the UK.

"I voted to give the First Minister a mandate to speak directly to Brussels and I was happy to do that.

"But I also want her playing a full part in the team that will represent all 65 million people across the UK - because, as the EU has already said, their only negotiation will be with the UK, and Scotland's interests need to be fully represented in that."

She added: "That is why today, I have written to the Prime Minister and to all the candidates for the Conservative Party leadership and emphasised that it is my view that the Scottish Government should be part of all negotiations on the UK's exit from the EU."

Responding to Dugdale, the Scottish Government said "all avenues" were being considered as to how to retain Scottish membership of the European Union.

The First Minister believes her government should be "fully and directly involved" in Brexit negotiations, a spokesperson added.

The Scottish Government said: "Our priority is to ensure Scotland's voice is heard and understood, and we are intent on pursuing all avenues to maintain Scotland's EU status, in line with the way people here voted.

"The First Minister has made it clear that the Scottish Government should be fully and directly involved in any negotiations and decisions about the next stages."

Scottish Greens' co-convener Patrick Harvie was sharply critical of Dugdale's speech, describing it as retreat to Scottish Labour's "old unionist stance".

Harvie said: "It took Labour just two weeks to abandon its open-mindedness to Scotland's constitutional future.

"It was only last week that a majority of MSPs in the Scottish Parliament, Greens and Labour included, voted to give the government a mandate to explore every avenue possible to keeping Scotland in the European Union.

"Now, Labour appears to have retreated to its old unionist stance, having learned nothing from working so closely with the Tories as part of Better Together."

He added: "Thankfully Scottish Green MSPs can provide a positive opposition in the Scottish Parliament that's actually prepared to work to keep Scotland in Europe and help build the fairer economy we know is possible."

Commenting on the Brexit result, Dugdale said politicians needed to "reach out" to those in Scotland who voted Leave.

She said: "This result a fortnight ago is a reckoning for the political establishment and we all need to come to terms with it.

"Here in Scotland, we are not immune. Over a million people voted Leave, but the public debate we've been having since the UK voted leave would make you think that we voted unanimously for remain.

She continued: "Here in Scotland there has been no attempt in the past two weeks to reach out to leave voters.

"There's been no effort made to find out why they voted the way they did and ask them why they were willing to risk a leap in the dark.

"The places where high Leave votes were found in Scotland are some of the poorest communities in our country.

"Many of them are also places that voted in large numbers for Yes in the Scottish (independence) referendum."

Dugdale also said her party and the "entire political class" had failed to listen to people's concerns.

She said: "Laying the blame for Brexit squarely at the Tories' door doesn't do justice to the depth of our country's problems.

"We in the Labour Party, and across the Labour movement, need to recognise that it wasn't just disenchantment with the Tory party that brought this Leave result home.

"It was disdain for an entire political class who look out of touch, elitist, deaf to the concerns that people are raising and with no answers to the big challenges our country is facing.

"We neither took on the points people were raising, or properly responded to them. As a Labour Party, we too rarely made a full throated defence of immigration."

She added: "People in Scotland - and across the UK - deserve better than the arguments they are getting right now.

"Giving simple answers to complex problems is part of the reason we have got to where we are today."