The UK and Welsh governments have reached agreement over a long-running Brexit “power-grab” row.
The agreement on changes to the UK Government EU (Withdrawal) Bill follows months of discussions.
Wales’ Finance Secretary Mark Drakeford said the deal means powers in areas “currently devolved remain devolved”.
Plaid Cymru leader Leanne Wood accused Labour of selling Wales “down the river” and capitulating to Westminster.
David Lidington, UK Cabinet Office minister, said the deal represented a “significant achievement that will provide legal certainty”.
The Scottish Government has rejected the latest offer, saying under the latest proposal the Scottish Parliament’s “hands would be tied”.
Up until now the Scottish and Welsh governments had been aligned in their stance against the UK Government, and there had been speculation for some time that the two may begin to differ in their approach.
The row centred on what would happen after the UK’s withdrawal from the European Union to 64 powers in devolved areas, such as agriculture support and food labelling.
The powers are currently operated by EU officials in Brussels.
As part of its EU (Withdrawal) Bill – which plans to transfer EU laws into UK law in order to avoid a legal “black hole” post-Brexit – the UK government had initially proposed that those powers should transfer to directly to Westminster rather than to the devolved administrations.
It led Welsh and Scottish ministers to label the proposed law a “naked power-grab”.
In February, the UK government said it had made a “considerable” offer, which would see the vast majority of those devolved powers returning to Cardiff, Edinburgh and Belfast while the rest temporarily stayed in London.
Although ministers in Cardiff said at the time the offer did not go far enough, following further discussions the UK and Welsh governments reached agreement on Tuesday on an enhanced proposal.
The agreed amendment is to be tabled by the UK government in Parliament on Wednesday.
It means any changes to powers held in Westminster would need the consent of the devolved legislatures, and that those powers will be held in Westminster for no more than seven years.
Finance Secretary Mark Drakeford said: “Our aim throughout these talks has been to protect devolution and make sure laws and policy in areas which are currently devolved remain devolved and this we have achieved.”
He said: “London has changed its position so that all powers and policy areas rest in Cardiff, unless specified to be temporarily held by the UK government.
“These will be areas where we all agree common, UK-wide rules are needed for a functioning UK internal market.
“In a devolved UK the respective governments need to deal with each other as equals and this agreement is a step in the right direction.
“This approach must now continue as we prepare for leaving the EU and the next phase of talks with Brussels,” he added.
Mr Lidington said: “This is a significant achievement that will provide legal certainty, increase the powers of the devolved governments and also respect the devolution settlements.”
He added: ‘It is disappointing that the Scottish Government have not yet felt able to add their agreement to the new amendments that Ministers and officials on all sides have been working on very hard over recent weeks.
“I thank them for that effort and hope that they may still reconsider their position.”
As an insurance policy in case agreement was not reached, the Welsh Government fast-tracked a so-called Continuity Bill through the assembly in a bid to safeguard Welsh powers.
Last week, the UK government said it would refer that bill to the Supreme Court to decide whether it could become law.
But following agreement on changes to the EU (Withdrawal) Bill, Welsh ministers now say they will withdraw their Continuity Bill as long as the UK government withdraws its Supreme Court action against the law.
Plaid Cymru Leader Leanne Wood said: “By capitulating to Westminster on the EU Withdrawal Bill, the Labour Government is selling Wales down the river.
“This is a bare-faced Westminster power grab which undermines the will of the people of Wales who voted for more powers in two referendums.”