The Scottish government is to launch a legal challenge to Westminster's block on its controversial gender reforms.
The proposals, which would allow people in Scotland to self-identify their sex, were passed by the Scottish Parliament in December last year.
But they were blocked by the UK government over their potential impact on UK-wide equality laws.
First Minister Humza Yousaf has previously described that move as an "undemocratic veto".
He was the only one of the three candidates in the SNP leadership contest who backed taking legal action in an attempt to overturn the block.
His predecessor, Nicola Sturgeon, had described the block as a "full-frontal attack on our democratically-elected Scottish Parliament" and said that legal action was inevitable.
Shirley-Anne Somerville, Scotland's social justice secretary, said the Gender Recognition Reform (Scotland) Bill had been passed by an "overwhelming majority of the Scottish Parliament, with support from members of all parties".
She said the block by the UK government was an "unprecedented challenge to the Scottish Parliament's ability to legislate on clearly devolved matters".
Ms Somerville added: "To uphold the democratic decision of the parliament, and ensure proper protection of devolution, Scottish ministers will now lodge a petition for judicial review of the secretary of state's decision.
She is expected to make a statement to the Scottish Parliament after the Easter break setting out details of her plans for a court challenge.
Prime Minister Rishi Sunak defended the UK government's decision to block the gender recognition reforms, saying it had been based on "very careful and considered advice".
He added: "We had concerns about how Scotland's gender recognition act would interact with reserved powers, about the operation of the Equalities Act, the protection of women elsewhere in the UK as well.
"Obviously there's a court process, we will follow that through."
The gender reforms have been divisive within the SNP, with another of the leadership candidates, Ash Regan, resigning from the government last year over her fears about their impact on safeguards for women and girls.
A recent opinion poll by Panelbase for the Sunday Times suggested that 18% of Scottish voters think Mr Yousaf should launch a legal challenge, while 44% said that he should abandon the reforms and 24% believed a compromise should be found with the UK government.
Shortly after the reforms were passed, double rapist Isla Bryson - who changed gender after being arrested for attacking two women - was remanded to a women's jail.
Bryson was subsequently moved to a male prison after the case sparked widespread anger. Ministers insisted the new legislation had no impact on the decision about where Bryson was held.
Scottish Conservative deputy leader Meghan Gallacher claimed that the legal challenge was a "painfully transparent attempt by Humza Yousaf to divert attention from the civil war engulfing the SNP and the huge question marks over the party's finances".
But the Scottish Greens, who have a power sharing agreement with the SNP, said the move was "vital for equality and democracy".
Mr Yousaf has previously said he would only launch a court challenge to the UK government's block if he was given legal advice that it stood a chance of succeeding.
But former Supreme Court judge Lord Hope has said the Scottish government's chances of winning a court case are "very low".
The former deputy president of the Supreme Court said the Scottish legislation "most certainly does" impact on the Equality Act 2010 and the existing Gender Recognition Act 2004, which currently apply across Great Britain.
And he said it was difficult to see how a court would not agree that Scottish Secretary Alister Jack had "acted reasonably" in blocking the reforms through the use of a Section 35 order.
The Scottish secretary is able to use a Section 35 to block legislation passed by Holyrood if he believes it would have a detrimental impact on areas that are reserved to Westminster.
It is the first time a Section 35 has been used since the Scottish Parliament was created in 1999.
Former SNP minister Alex Neil told BBC Scotland earlier on Wednesday that "every lawyer I have spoken to has told me we don't have a cat in hell's chance of winning" a legal battle.
He said Mr Yousaf should instead focus on reintroducing the legislation after its "deficiencies" had been addressed.
Susan Smith, co-director of the For Women Scotland group - which opposes the gender self-identification reforms - said Mr Yousaf was "remarkably foolish" to take legal action over legislation that is "wildly unpopular".
She added: "It is widely predicted that they will lose, so it seems like an incredible waste of everybody's time and money to go through this when there are other really pressing matters".
However, the announcement of a legal challenge was welcomed by Vic Valentine, the manager of Scottish Trans, who said the UK government's block was "unacceptable".
They added: "Other countries all over the world have introduced similar laws, with the only impact being a positive one."
Colin Macfarlane, the director of nations at Stonewall, said the UK government's "unprecedented" block had "made clear that they see trans people as a threat to be contained rather than people to be treated with dignity and respect".
The reforms are intended to make it easier for people to change their legally-recognised sex by doing away with the need for a medical diagnosis of gender dysphoria - a sense of unease that a person may have because of a mismatch between their biological sex and their gender identity.
Applicants for a gender recognition certificate would need to have lived in their acquired gender for three months rather than the current two years.
And the minimum age that someone can apply to change their sex will be cut from 18 to 16 - although 16 and 17-year-olds would need to have lived as their acquired gender for six months rather than three.