Negotiations between the Scottish and UK governments over key Brexit legislation are "reaching the end game", the First Minister has said.

Nicola Sturgeon said ministers have "days rather than weeks" to reach a deal on the EU Withdrawal Bill, which has entered its final stages in the House of Lords.

Scottish secretary David Mundell has also said the talks would "go to the wire".

The UK Government remains locked in a dispute with the Scottish and Welsh administrations over where powers on certain devolved areas will lie after they are returned from Brussels.

Ministers in both Cardiff and Edinburgh have repeatedly branded the legislation a "power grab" which threatens the devolution settlement and have refused to recommend consent unless it is amended.

Meanwhile, the UK Government has launched a legal challenge to alternative Brexit bills passed by the Scottish Parliament and Welsh Assembly.

Speaking at an evidence session with Holyrood's committee conveners, Sturgeon said the referral to the Supreme Court was "deeply regrettable".

"The Westminster government had a decision to make, whether to respect the decision the Scottish Parliament arrived at or not to respect it, and unfortunately they opted not to and referred to the Supreme Court," she said.

She added that the decision had a "bearing on the spirit of the negotiations" on the EU Withdrawal Bill, with time running out to reach an agreement.

"I think it's fair to say we are reaching the end game of this," she said.

"We know the stage the withdrawal bill is at in terms of being at the report stage in the Lords, so we will probably over the next couple of weeks need to see this come to an agreement or not.

"We are talking now more like days rather than weeks."

She added: "I genuinely hope we can reach agreement but inevitably when there is pretty fundamental issues of principles involved, the bar for agreement is not always easy to overcome."

Speaking on BBC Radio Scotland's Good Morning Scotland programme, Mundell said: "I'm afraid the discussions and negotiations will go right up to the wire, but I am confident that we can reach an agreement."

He added: "The court referral is about seeking clarity, seeking certainty when different views have been expressed."

He was unable to confirm the estimated cost of the legal challenge, adding: "We're only at the very start of the legal process.

"It costs £200 to refer the case to the court. Obviously, if the case became involved in a protracted discussion there is greater cost.

"It's very important that when you see two different views expressed about a piece of legislation, that actually somebody gives a definitive view, is it competent or is it not."