Feijóo led the conservatives to victory in 2023 but did not have enough allies to form a coalition. Even though the conservatives picked up over a million votes more than three years ago, Spain's electoral system meant they actually lost seats.
Combined with Vox and a small centre-right ally in the Navarra region, the parties were heading for a 10-seat majority in parliament, signalling a clear change in Spanish politics.
The result reaches beyond Madrid. Sánchez was the most high-profile of only a handful of left-wing leaders in power on the continent, and Spain's election has been scrutinised closely across Europe, with votes in several key EU states set to take place over the next year.
"Spain has called for change, and sweeping change,"Feijóo told supporters, promising that the PP would try to govern for everyone,"no matter who they voted for".
"We're going to govern without fear and we aren't going to lose a single day,"the PP leader said. At 65, he is in many ways the antithesis of his Socialist rival.
As winner, the People's Party will want to assert its own centre-right programme over the next government. It will still have to reach a deal with Vox if it wants a stable administration.
With 52 seats, Vox would very much become the junior partner. There is some question over how far it can push its policies on a national level.
After eight years in power, Sánchez said his"progressive bloc"had not been strong enough, but he told his party not to give up.
He had hoped that a historically high turnout, just shy of 80%, would be good news for the Socialists. The reality was far different.
"It's about time there was a change after eight years of misrule,"said Fabian, 21, referring to a raft of corruption scandals that have plagued Sánchez's inner circle.
More than 1.6 million Spaniards were eligible to vote for the first time on Sunday. There was widespread evidence that many young people had decided not to back the Socialists and their allies.
Voters have faced big increases in the cost of living, and house prices have risen 108% since 2013.
"Spain needed a change,"said Bárbara, 17, as she danced with her friend Flavia.
One mother and her daughter, who was voting for the first time, told the BBC they wanted Vox to tackle immigration, support farmers and invest in the railways.