Spanish election: PP wins most seats but deadlock remains
Spain's other main party, the Socialist PSOE, is in second place.
The left-wing Unidos Podemos alliance and centre-right Ciudadanos are third and fourth.
The vote has failed to break six months of political deadlock since December's inconclusive poll. But Mr Rajoy said he had a right to resume office.
"We have won the elections, we demand the right to govern," he told hundreds of cheering supporters at a victory rally in Madrid on Sunday evening.
Official results give the PP 137 seats in the 350-seat parliament, up 15 from the 122 they won the December ballot.
The PP now faces a similar challenge to form a government as after the December poll. It needs support from a number of other parties in order to achieve a voting majority.
The prospects of resolving the political stalemate do not look good.
It was the failure of previous attempts to agree a coalition that sparked a re-run of the ballot in the first place, and Sunday's election resulted in no major changes.
The PP won the election and even increased its support - but not by enough to govern alone.
So once the celebrations stop, the wrangling over coalitions will begin and it will not be easy.
The other surprise from Sunday's vote was that the left wing protest party Podemos did not soar in the polls. It is possible that voters were turned off more radical parties, after the UK voted for to leave the European Union - and shook Spain's fragile economy.
Spain has endured six months of political paralysis. All parties are now under pressure to reach a compromise, form a coalition, and get back to the business of governing.
The PSOE won 85 seats, confounding an earlier exit poll suggesting it would slip into third place, but still five fewer than in December.
All the other parties lost votes or seats, or both. Unidos Podemos and Ciudadanos, both relative newcomers, won 71 and 32 seat respectively.
Unidos Podemos was the worst-affected, losing more than a million votes and failing to meet expectations that it would become the country's main left-wing party.
Source: bbc.com