Shortly before, acting PSOE leader Javier Fernandez had officially informed King Felipe VI that his party would abstain in the second round of a confidence vote for Rajoy as PM.
"I accepted the task", Rajoy told reporters after meeting Spain's king.
Oct 25 Spain's parliament will begin discussing acting Prime Minister Mariano Rajoy's bid for a second term in office on Wednesday, the house speaker said on Tuesday.
But it will be weak as far-left Unidos Podemos and centrists Ciudadanos - the two upstarts that put an end to Spain's traditional two-party system in both elections - will join the Socialists in the opposition, making things hard for the PP.
The decision to help a conservative government get to power has caused huge divisions among the Socialists - so much so that party chief Pedro Sanchez, a fierce opponent of Rajoy, was forced out earlier this month after a rebellion. Although Rajoy's PP won both elections, the center-right party lacked an outright majority. Barring a major upset, he should be elected premier over the weekend.
This resulted in a fragmented parliament where no grouping had enough lawmakers to govern alone, even if Rajoy's PP remained the biggest single party. The 137-year-old party is trying to avoid the fate of Pasok, its Greek counterpart, as its leaders wrestle with the its worst-ever election results and the rise of the anti-establishment insurgents of Podemos.
This story has been corrected that the Socialists have 84 seats, not 85.
The Socialists, who had previously voted against a Rajoy-led government, switched position last Sunday by announcing they would abstain in the next confidence vote on Rajoy, paving the way for him to stay in power. Some regional leaders are threatening to rebel and vote against Rajoy, but this is unlikely to change the outcome.