"The Spanish people have spoken clearly and decided to start a new era," Zapatero told supporters outside party headquarters in Madrid, quoted the Associated Press. "I will govern with a firm but open hand."
The Socialists gained five seats for a total of 169 in the 350-seat Cortes Generales, or parliament, Reuters reported.
The conservative Popular Party also garnered five seats to total 153, while smaller left-wing and regional parties lost seats.
Turnout for the election, estimated at 75 percent, almost matched 2004 when the Popular Party government's handling of an Islamist attack on Madrid's trains -- blaming Basque separatist group ETA instead at first -- produced a surprising win by the Socialists.
The lead-in to this year's election had its own bout of violence when former Socialist councilman Isaias Carrasco was shot to death while leaving his home with his wife and daughter on Friday. Some believe that attack, apparently perpetrated by ETA, may have prompted sympathy for Zapatero's party, according to the AP. On Saturday, Carrasco's 20-year-old daughter Sandra made a public appeal to voters to defy ETA and turn out in droves on Election Day.
Zapatero portrayed his victory on Sunday as an endorsement of his initiatives, including legalizing gay marriage and granting on-demand divorce. During his first term, he also withdrew Spanish troops from Iraq and worked to grant more power to Spain's semiautonomous regions.
In this term, he faces the challenges of a slowing economy, brought on by the global credit crunch, and the resurgence of ETA, which ended a cease-fire in December 2006.