The Socialists led by Prime Minister Jose Luis Rodriguez Zapatero, who came to power four years ago, face the conservative Popular Party headed by Mariano Rajoy. The election campaign focused on economic matters amid the faltering economy, rising prices and unemployment, and also concerns over immigration.
The voting was marred by the killing of a former Socialist town councilor in the Basque region on Friday. The attack was blamed on the Basque separatist group ETA.
Polling stations opened at 08:00 GMT and will close at 19:00 GMT.