Rajoy's conservative Popular Party won the most ballots in Sunday's vote but lost its absolute majority in the 350-seat lower house of parliament, taking just 123.
The opposition Socialists won 90 seats, followed by the far-left Podemos with 69 seats and the centre-right Ciudadanos with 40.
Rajoy in January will face a vote of confidence on whether he can stay on as leader of the government.
If he falls short a second vote will be held 48 hours later with a lower bar to success -- he would just need to get more votes for than against him that time around.
That means if Ciudadanos and the Socialists were to abstain from voting in the second vote Rajoy would be able to get re-elected.
Ciudadanos, which shares many of the Popular Party's economic policies, has said it will abstain.
But the leader of the Socialists, Pedro Sanchez, said today his party would not support any effort by Rajoy to stay in power.
Sanchez did not completely close the door on the Popular Party -- he did not say if the Socialists would support the party if Rajoy were to step down as leader.
The Socialist leader reiterated that the Popular Party should be the first to try to form a government since it won the most votes. But he said if the party failed, his formation would "explore all options for there to be a government of change".
That outcome would mirror events in neighbouring Portugal where the ruling conservatives won an October election but fell to a Socialist government backed by leftist parties just days later.
