Deferr performed two strong efforts in the final to complete his comeback, after he placed fourth in the men's floor exercise final on Sunday.
It was his finest performance since he came back from a three-month suspension in early 2003 after testing positive for cannabis the previous October.
"Today I was able to show I can do the job," he said. "I do realise I made a mistake and I got caught but there was no doubt in my mind that I could make it back."
STRONG PERFORMANCE
Deferr's gold medal topped a strong performance overall from Spain's male and female gymnasts at the Athens Games.
Spanish gymnasts recorded all-time bests in the men's and women's all-round events, the women's team competition, and reached four individual event finals, where their qualifiers all put in strong performances.
Deferr was not Spain's only medallist on Monday with Patricia Moreno earning a bronze medal on the women's floor exercise.
The previous day, Victor Cano had earned fifth on the pommel horse final after drawing the dreaded first spot in the finals lineup.
Spain also succeeded in the all-round with Rafael Martinez rising to fifth place in the men's event and Elena Gomez taking eighth on the women's side.
In the team events, the Spanish men were 10th in preliminaries and the women bettered them with a fifth-place spot in the team final.
Cano, who has become known for excellent form and technique, said Spain's success started with the 1996 world horizontal bar title won by Jesus Carballo, who is also a member of the 2004 squad.
Cano said Deferr's 2000 Olympic vault title in Sydney was another important step in Spain's gymnasts being properly recognised by the judges.
"We have good athletes now and our coaches know more than they did four or five years ago," he said. "People have more respect for us. It's not like eight years ago when it was a struggle to get the scores we deserved."