Rajoy told reporters King Felipe VI had asked him if he would attempt to form a government, adding he had "accepted this assignment" and would work to get the support he needs -- a challenge as most other parties refuse to back him.
The country has been without a fully-functioning government for seven months, leaving it in political limbo at a sensitive time as it needs to take urgent steps to reduce its deficit as well as address a growing separatist movement in the Catalonia region.
The blockage started after elections on December 20th failed to give any party an absolute parliamentary majority, as upstart groupings Ciudadanos and Podemos shook up Spain's long-established two-party system.
Fed up with years of austerity and repeated corruption scandals, millions of Spaniards tasked the two upstarts to revitalise the country.
But efforts to forge a coalition were unsuccessful as rival parties were unable to overcome their differences, prompting repeat elections in June with a similar result.
Rajoy's Popular Party (PP), in power since 2011, won the June 26th vote with 137 seats out of 350.
Although its victory margin was wider than in the December polls, the conservative party still failed to achieve an absolute majority.
'Starting to get fed up'
After the last elections, Rajoy had relinquished the task of forming a government due to lack of support, forcing the king to nominate runner-up Socialist party chief Pedro Sanchez instead.
But he too failed to garner enough support as far-left Podemos -- which came third -- refused to back him, prompting the repeat elections.
This time round, Rajoy faces a similarly difficult task.
He needs to get enough support from other parties to push a coalition or minority government through a parliamentary vote of confidence -- be it with ballots in favour or abstentions.
But Sanchez has already said that his party -- which with 85 seats has the power to block the PP -- will not back him, as has Podemos.
Ciudadanos chief Albert Rivera meanwhile has said his party will abstain in a vote of confidence, though with its 32 seats, this will still not be enough for Rajoy to push his government through.
The date for the vote has yet to be set and Spain still faces weeks of uncertainty, particularly as the PP and Socialists appear far from reaching any kind of agreement.
"The Spanish... are starting to get fed up," Rivera told reporters earlier Thursday after meeting with the king.
"The 'old parties' have no excuse to avoid sitting at a table and negotiating."
Failure to come to an agreement would eventually prompt a third round of elections -- a situation Rajoy said he would work to avoid.
"I will do all I can so that Spain gets a government, but it doesn't only depend on me," he said.
By Marianne Barriaux