With members of the main opposition Popular party favouring the move to boost the contingent, the resolution was passed on Tuesday by 302 votes to 10.
The number of Spanish soldiers serving with NATO forces in Afghanistan would be increased during the election period to a maximum of 1040 from the current 475, before being scaled back to 540 at the end of the year.
The parliament also voted by 307 votes to three to contribute 110 civil guards to the United Nations stabilisation force in Haiti.
The UN force in the Caribbean country is expected to eventually total 6700 soldiers, 1622 police officers and 900 civil servants.
Socialist Prime Minister Jose Luis Rodriguez Zapatero told deputies he wanted Spain to help the international community but also “strictly respect international law”.
Zapatero said his government would shortly put forward a bill before parliament to ensure its “real participation” in decisions to send troops overseas.
Spain last month completed the withdrawal of its 1400-strong military contingent in Iraq.
The troops had been sent into Iraq by Zapatero’s conservative predecessor, Jose Maria Aznar, who strongly backed the US-led invasion and occupation.