“His majesty the King nominated him to form a government. Mr Mariano Rajoy thanked his majesty the King but declined the offer,” the statement said.
The king will now hold a fresh round of consultations to chose another candidate.
The PP won the most seats (119) in the December poll but fell well short of an absolute majority in the 350-seat parliament
Rajoy had called for a “grand coalition” of the PP, the Socialists who came in second place winning 89 seats, and new centre-right party Ciudadanos which took 40 seats.
– 'Majority against me' –
But with no party expressing any intention of voting for Rajoy, and with only Ciudadanos offering to abstain from voting, Rajoy decided to withdraw.
“For the moment, I don't have the necessary support. I am maintaining my candidacy but I cannot present it today because not only do I not have a majority but there is a majority against me,” he told reporters.
Earlier on Friday, the leader of Spain's anti-austerity party Podemos proposed forming a government with the Socialists, making a left-wing governing alliance more likely.
Pablo Iglesias told reporters he had informed King Felipe VI of “our desire to form a government of change with the Socialists and the United Left”.
Socialist leader Pedro Sanchez should lead the government with the Podemos leader himself as deputy, said Iglesias.
Podemos, a close ally of Greece's ruling Syriza which came third in a general election on December 20th, had so far not said if they would try to form a government with the Socialists.
Last month's general election produced a hung parliament with no easy way of forming a ruling coalition majority.
A future government must win a vote of confidence in the assembly before taking office.
Socialist leader Pedro Sanchez has rejected the PP's advances and instead wants to form a left-wing alliance of “progressive forces” that includes Podemos and its allies who have 65 seats along with the United Left with two seats.
Sanchez welcomed the Podemos proposal but said the two parties needed to first reach an agreement on a programme.
“Podemos and Socialist voters would not understand if we did not reach an agreement,” he told a news conference after he met with the king.
The formation of a left-wing coalition government has been complicated by Podemos' backing for an independence referendum in the wealthy northeastern region of Catalonia, which Sanchez fiercely opposes.
But Podemos, which did well in Catalonia, appears to have softened its position on the issue in recent days, saying it wants to focus on economic and social issues rather then the Catalan question.
– Support first –
The head of the United Left, Alberto Garzon, accepted the proposal and said he hoped negotiations could begin as soon as possible so there was a left-wing “government of change” as in neighbouring Portugal and Greece.
A left-wing coalition government would still need the support of tiny Catalan and Basque nationalist parties to survive a confidence vote in the event that Ciudadanos decided to vote for the PP.
Parliament has two months from the first confidence vote to approve a new government before fresh elections are triggered.
Sanchez said the PP should get the first chance at forming a government because it won the most seats in December and such a move would also respect “procedures”.
Several PP lawmakers had in recent days tried to convince Rajoy not to not submit himself to a vote of confidence to avoid a humiliating defeat, a PP lawmaker who asked to remain anonymous told AFP.
Iglesias said a left-wing government would adopt measures within the first 100 days to prevent evictions of homeowners struggling to pay their mortgages and do more to help the long-term unemployed whose benefits have run out.
He also said a left-wing government would honour Spain's debt but “reduce the deficit at a slower rhythm” and would adopt measures to fight corruption and reform the justice and electoral system.