The UK government has announced a ban on some drug exports to protect NHS patients' access to medicines.
The 24 medicines affected include hormone replacement therapy drugs, contraceptives and adrenaline pens.
The move comes after a survey of local pharmacists found shortages of every major type of medicine in the past six months.
Ministers said the restrictions were not linked to Brexit and medicine shortages did occasionally occur.
Pharmaceutical industry leaders welcomed the move, saying stockpiles of medicines would now be better protected and available for NHS use only.
The government restrictions will stop wholesalers selling some medicines meant for UK patients for a higher price in another country, potentially causing or worsening supply problems.
About 360,000 prescriptions of HRT, which relieve symptoms of the menopause, are dispensed every month,
But these drugs, along with contraceptives and anti-epileptic drugs, are in short supply, according to a UK-wide survey of 402 community pharmacies by the Chemist and Druggist.
The government has also introduced a "serious shortage protocol" for the antidepressant Fluoxetine, which allows pharmacists to give patients an alternative strength or form of the drug because of temporary shortages of some doses.
Health Secretary Matt Hancock said: "I know how distressing medicine shortages can be for those who rely on drugs like HRT and it is absolutely crucial patients can always access safe and effective treatments through the NHS."
The new measures would help "ensure patients get the medicines they need", he added.
Dr Rick Greville, from the Association of the British Pharmaceutical Industry, said: "It means that these stockpiles of medicines which companies have built over previous months are better protected and available for use only by the NHS patients for which they were intended.
"Companies can now work with the [health] department to identify any problem areas."
This is an unprecedented move for the UK.
Some other EU countries have considered such action or implemented measures in the past to stop the flow of drugs out of their countries.
The Greek authorities, for example, banned exports during the financial crisis.
But it's the first time the government has decided the risk of shortages for NHS patients requires intervention to protect supplies.
UK wholesalers with regulatory licences have the right to move stocks of drugs to sell in other European markets if they wish.
The incentive to do so in the eurozone increases as the pound weakens.
Now, they have been told they will lose those licences if they shift products elsewhere.
Officials say the risk of the UK leaving the European Union without a withdrawal agreement in place is not the reason for the new policy, as shortages do occur from time to time in the medicine markets.
But that is certainly the backdrop to the new export ban, as ministers decide action is needed to protect existing supplies.
Dr Farah Jameel, from the British Medical Association, said there were lots of different reasons why drugs shortages happened.
"But they are gradually getting worse and can have a serious effect on how quickly patients receive appropriate treatment," she said.
"Practices often won't know that a drug is in short supply until patients return from the pharmacy and these extra GP appointments can dramatically add to their already burgeoning workload - as well as distressing patients."
Patients should continue to order their repeat prescriptions and keep taking their medicines as normal - but not ask for more medicines than they need, the Department for Health and Social Care said.
It added it was working to ensure the supply of medicines and medical products "remains uninterrupted after 31 October, [when the UK is set to leave the EU,] whatever the circumstances".
The government has made arrangements to stockpile six weeks' supply of drugs for the NHS in case of a no-deal exit from the EU.
But a recent report said it was not clear exactly what level of stockpiling was in place.