The UK's mobile networks are to be forbidden from selling phones locked to their services from December 2021.
Regulator Ofcom said unlocking handsets could often be a complicated process, and this was discouraging owners from switching providers at the end of their contracts.
The networks have previously suggested that locking devices helps deter theft and fraud.
But the watchdog noted some companies had already abandoned the practice.
Among those companies affected are:
BT and its EE mobile division
O2, Sky, Three and Virgin already only sell unlocked handsets.
"[It] will save people time, money and effort - and help them unlock better deals," said Ofcom's connectivity director Selina Chadha.
Vodafone has already responded: "We stand ready to implement these changes when they come into force."
EE added: "We'll work with Ofcom to comply with its guidelines."
It typically costs about £10 to get a smartphone unlocked to let it work on any network.
However, according to a study by Ofcom, about half of all those who try to do so experience difficulties.
These can include facing a long wait to receive the code needed to trigger the process, as well as then finding that the code does not work.
The regulator added that some owners do not realise their devices are locked in the first place, causing them to suffer a loss of service when they try to switch.
The ban means the UK remains compliant with wider European rules, but Ofcom noted that it was already looking into the problem before the EU introduced the regulations in 2018.
The UK government has said it will adhere to the European Electronic Communications Code, despite planning to complete the Brexit transition period this year.
The locked handsets ban is one of several new measures that telecoms providers will have to follow.
an obligation to provide communications in accessible formats - such as braille - when requested. This must also be done by December 2021
giving customers a stronger right to leave if changes are made to deals that they were not told about before signing. This will come into force in June 2022
a requirement that customers be shown a clear summary of a contract's key parts before joining. This must happen by June 2022
In addition, the regulator plans to make it easier to switch broadband providers by December 2022.
At present, if customers switch from one provider reliant on BT's Openreach network to another - for instance from Sky to TalkTalk - all they need to do is contact the new supplier, which makes all the arrangements.
But if they want to move to another broadband network - for example from BT to Virgin Media or CityFibre - they have to manage it themselves.
Ofcom had asked the industry to come up with a process to end this discrepancy.
But after it failed to do so, officials are now working on their own solution, although they say they will consult the public and the companies involved first.