The decision by the UK Medicines and Healthcare products Regulatory Agency follows a public consultation. It will be up to pharmacists to judge whether men over the age of 18 can safely be sold the little blue pills.
Manufacturer Pfizer hopes to get stocks of Viagra Connect (sildenafil 50mg) into UK pharmacies by spring 2018.
Experts say making the medication more widely available will help men who might not feel able to visit their GP about impotence. The MHRA hopes it will stop some men buying unregulated medicines from websites operating illegally.
Mick Foy, MHRA's group manager in vigilance and risk management of medicines, said: "This decision is good news for men's health. Erectile dysfunction can be a debilitating condition, so it's important men feel they have fast access to quality and legitimate care, and do not feel they need to turn to counterfeit online supplies which could have potentially serious side-effects."
Pharmacists will decide whether treatment is appropriate and can offer advice on erectile dysfunction, usage of the medicine, potential side-effects and whether further consultation with a general practitioner is required.
Viagra Connect will not be sold to: those with severe heart disease or at high risk of cadiovascular disease, those with liver failure, those with severe kidney failure
men taking certain medicines that could cause a bad reaction when combined with Viagra.
Men who are sold it will be advised that they can take a 50 mg tablet an hour before having sex, but should not use more than one pill a day.