WADA declared Spain's anti-doping agency AEPSAD as non-compliant in March 2016.
A delay in updating Spain's anti-doping laws in line with WADA's stricter code introduced in 2015 had been blamed on a 10-month political deadlock that left the country without a ruling government from December 2015 to October last year.
"With the passing of this law, Spain is in the position to reverse the non-compliant status with the WADA code," AEPSAD said in a statement.
The bill still needs to be passed by parliament to become law.
The most significant reforms will see doping bans doubled from two to four years.
Suspensions can also be levied on anyone complicit in aiding in the doping of an athlete, including doctors, coaches and team directors.
Furthermore, the statute of limitations for bans due to doping offences will increase from eight to 10 years.
Last week WADA expressed its "alarm" that no binding drug testing has taken place in Spanish football for nearly a year.
Unlike in other sports where international federations had taken over responsibility to carry out drug testing whilst AEPSAD's Madrid laboratory is declared non-compliant, football governing bodies FIFA and UEFA had refused to do so.
WADA was also part of a series of bodies who won an appeal in June against the destruction of 211 blood bags seized in an anti-doping raid on disgraced Spanish doctor Eufemiano Fuentes.
The case was a major contributory factor in Madrid's unsuccessful bid to host the 2020 Olympics.