Rajoy's conservative Popular Party (PP) was the big winner of Sunday's elections, the second in six months, which played out against a background of turbulence from Britain's shock vote to leave the European Union.
Shares in Spain's main Ibex 35 rose more than three percent in the morning to 8,023.70 before going back down again as traders celebrated the conservative election win.
The PP won 137 seats in the 350-strong lower house of parliament, beating expectations and its previous score in December polls, but still leaving it far short of a majority which means Rajoy needs support from other parties to form a government – no easy task.
“We won't support Rajoy,” said Cesar Luena, number two of the Socialist party.
Rajoy will need to seek the outright or tacit support of other parties to get a coalition or minority government through.
It could team up with market-friendly upstart Ciudadanos, its natural ally, but their combined total number of seats will still not be enough to form a majority centre-right government and push it through the necessary vote of confidence.
So they may need to court smaller regional parties or the Socialists (PSOE), which came second in Sunday's elections with 85 seats, its worst score in modern history.
The PSOE could decide to abstain in the parliamentary vote to let a government through and avoid taking the country to a third round of elections.
But angry over a string of corruption scandals that have hit the PP and severe austerity measures under Rajoy's watch, it is unlikely to back a centre-right government with him at the helm.
Asked whether the Socialists would consider abstaining, Luena said this would be an issue they would discuss when the time came.
“But PSOE wants to replace Rajoy,” he said.
The election result was broadly the same as that of last polls in December, when far-left upstart Podemos and Ciudadanos uprooted the country's two-party dominance.
The PP came first, Socialists second, followed by a far-left coalition led by Podemos and Ciudadanos in fourth place.
Apart from the PP, which won more seats, the other three parties lost votes or seats – in some cases both.