The government said that the mission was part of a risky but vital attempt to achieve lasting Mideast peace. Parliament voted overwhelmingly in favour of the deployment on Thursday afternoon.
The decision will make Spain the third-largest contributor to the expanded United Nations Interim Force in Lebanon behind France and Italy.
The UN force, which aims to eventually number 15,000 troops, aims to enforce and monitor the ceasefire between Israel and Hezbollah in southern Lebanon.
The first Spanish troops - about half of the total contingent - were to leave Friday for Lebanon from a port in southern Spain.
Of 308 politicans present in the 350-seat lower chamber of Spain's parliament, 306 voted in favor, none against and two abstained after five hours of debate.
The socialist government's conservative rivals voiced begrudging support for the mission, but called it dangerous.
Lebanon not like Iraq
Jose Luis Rodriguez Zapatero, the Spanish prime minister, angrily rejected the conservatives' assertions that the mission to Lebanon was comparable to Spain's involvement in the Iraq war in 2003.
Zapatero had opposed the deployment of troops to Iraq. When he took power in April 2004 he abruptly brought home all 1,300 Spanish soldiers based in southern Iraq.
Zapatero said that the deployment to Lebanon was different because the mission was requested and approved by the United Nations and enjoys a broad international consensus.
"This is exactly the opposite of what happened with the military intervention in Iraq," Zapatero told parliament during the debate.
"Based on the same principles and the same convictions with which it opposed the war in Iraq and withdrew the troops from Iraq, the government now asks the chamber to send our soldiers to Lebanon to guarantee peace."
The Iraq war was widely unpopular in Spain, and the conservative Popular Party was voted out of office in elections three days after Muslims killed 191 people when they set off bombs at a train station in Madrid.
The bombers said they had acted on al-Qaeda's behalf in response to the Spanish military presence in Iraq.