"The goal is to protect people's health and avoid possible adverse effects," Health Minister Ana Mato said in a statement.
The ban on the use of the battery-powered devices, which contain liquid nicotine that is turned into a vapour when inhaled, will also apply to health centres, public administration buildings and public transport.
The health ministry reached an agreement to impose restrictions on the use of e-cigarettes with the health departments of Spain's 17 autonomous regional governments, which are responsible for healthcare, at a meeting in Madrid.
Spain already bans minors from using e-cigarettes.
Under Spain's anti-tobacco law, one of the strictest in Europe, smoking is banned in bars, restaurants, discotheques, casinos, airports as well as in outside places such as outside hospitals and children's playgrounds.
Governments around the world have struggled with how to regulate e-cigarettes since their emergence and growing popularity in recent years.
Supporters claim they are a less dangerous alternative to regular cigarettes and a valuable tool in helping smokers to quit.
However, the World Health Organisation has advised against them, saying their potential health risk "remains undetermined".
In October European lawmakers rejected a bid to classify e-cigarettes as medicinal products, which would have restricted their sale to pharmacies.
But European Union states and lawmakers agreed on Wednesday to regulate nicotine content in both the devices and refills will be regulated.
About seven million Europeans have turned to e-cigarettes in the last four years.