Lawmakers voted 173 against 135 -- and 32 abstentions -- to examine the bill, which was originally drafted by Catalonia's regional assembly, presstv.ir reported.
This is the first time that a bill aimed at legalizing euthanasia makes it past this first hurdle after previous attempts failed, a parliament spokeswoman told AFP.
It seeks to modify part of article 143 of Spain's penal code, which currently bans anyone from causing or cooperating with the death of another person suffering from "a serious, terminal illness or one that causes serious, permanent ailments that are difficult to endure."
The bill would make it legal for a person to cause or help cause the "reliable, peaceful, painless death" of another suffering from those problems if they "specifically, freely and unequivocally" ask for it.
Currently in Spain, people with incurable diseases only have the option to refuse treatment.
But according to an opinion poll conducted by research firm Metroscopia in March 2017, 84 percent of Spaniards are in favor of allowing people with terminal illnesses to be helped to die "painlessly."
Lawmakers from Spain's conservative ruling Popular Party and another from the regional party of Navarra voted against accepting the bill on Thursday.
Center-right party Ciudadanos, meanwhile, abstained, while all the other groupings in parliament -- most of them left-wing -- voted in favor.
Now that it has passed the first hurdle, the bill will go through various stages in parliament -- with different groups likely to present their amendments -- before it gets to the final voting stage in the lower house.