Alberto Núñez Feijóo's conservative People's Party (PP) is ahead in most opinion polls and is prepared to govern with far-right Vox.
Such a coalition would put an end to Sánchez's time in office.
Surveys give the PP about 32 percent support, around two points more than its main rival, the prime minister's Spanish Socialist Workers' Party (PSOE).
Santiago Abascal's Vox is third in various polls, on roughly 18 percent.
Sánchez called the snap vote after parliament rejected two decrees at the beginning of October.
The measures were designed to limit rents and protect tenants from eviction.
Housing – both its cost and availability – has been a central campaign issue, alongside corruption scandals in the prime minister's inner circle, migration and the economy.
The Socialists and a left-wing bloc want greater state involvement in the property market and more social homes to be built.
By contrast, the PP and Vox favour fewer restrictions and lower taxes.
The far-right party also wants Spaniards to have priority access to social housing.
Polling stations opened at 09:00 a.m. local time.
Voters are choosing all 350 members of the Congress of Deputies, the lower house, and 209 senators for a four-year term.
First results are expected overnight into Monday.
The new parliament is due to convene on 23 December.
King Felipe VI will then nominate a candidate for prime minister – usually the leader of the party that wins the most votes.
(ał)
Source: PAP, IAR
Ahead of the vote, Danuta Isler spoke to Berta Dacasa and Alejandro González, two Spanish students taking part in the Erasmus exchange programme at the University of Warsaw, to find out what is at stake.
Click on the audio player above to listen.