The patient, identified by media as a man aged 50, was admitted in the northwestern city of A Coruña for a separate illness and came down with the lung complaint while there, a source at the hospital told news agency AFP.
"He was diagnosed with exogenous lipoid pneumonia caused by an excessive use of electronic cigarette," said the source at the A Coruña University Hospital, who asked not be named.
The disease was caused by a vegetable-based ingredient in the replaceable cartridges that produce the vapour for inhalation, the source added.
Doctors diagnosed the pneumonia "a few days ago" and the patient has since been cured and discharged, the source said.
"According to the medical journals, it is the second case in the world of a breathing complaint related to consumption of electronic cigarettes."
The US specialist medical journal Chest in April 2012 recorded the case of a 42-year-old woman who also caught pneumonia from using e-cigarettes.
Makers of e-cigarettes say they are much less harmful than tobacco and can help people give up smoking. They brushed off the case in A Coruña.
"There is no proof that this illness was linked to use of an electronic cigarette," said Alejandro Rodriguez, vice-president of the National Electronic Cigarette Association, which represents 500 companies active in Spain.
"How many people die every day from smoking? If in the 15 years that e-cigarettes have been around only two people in the world have caught light pneumonia from this product, we should say well done to it," he told news agency AFP.
The battery-powered devices deliver a puff of nicotine vapour in a variety of possible flavours, minus many of the toxic chemicals present in tobacco.
They are becoming an increasingly popular alternative to tobacco but experts have yet to determine how harmful they may be to people's health.
Experts at a conference in London last November said about seven million Europeans have turned to e-cigarettes in the past four years.
In December, the European Union agreed to regulate the e-cigarette market and Spain said it would ban them from public places like hospitals and schools.
In the United States, lawmakers in the cities of New York and Los Angeles have voted to ban e-cigarettes in public.
Some 600,000 to 800,000 Spaniards use e-cigarettes according to Spain's National E-cigarettes Association (ANCE).
About seven million Europeans have estimated to have turned to e-cigarettes in the past four years and Euromonitor estimates the business was worth €1 billion worldwide in 2012.