Sunday's election is expected to be one of most closely fought contests in years as anger over corruption scandals and a long economic crisis has fuelled the rise of newcomers that are threatening the traditional dominance of Rajoy's Popular Party (PP) and Pedro Sánchez's PSOE party.
Sánchez seized the only chance an opposition candidate has had to debate Rajoy in public, firing off multiple attacks on his integrity and ability to govern.
“The head of the government, Mr Rajoy, has to be a decent person, and you are not,” said Sánchez, accusing the premier of repeatedly lying to the public and demanding to know why he had not resigned over corruption allegations that have swirled since he took office.
“If you remain in office, the cost to our democracy will be enormous,” Sánchez added.
In response, Rajoy said he was an “honest politician”.
“You are young and you are going to lose these elections, but you can recover from that. What you cannot recover from are the contemptible and mean allegations that you have made. If you have something against me, take me to court,” he added.
A long-running graft probe into the conservative PP, which took power four years ago, has been a source of great embarrassment to the party. Former treasurer Luis Bárcenas has admitted running a slush fund he claimed had benefited powerful party figures.
In July 2013, Bárcenas testified in court that he handed cash to Rajoy, but the prime minister and other senior party members denied receiving any undeclared payments and kicked Bárcenas out of the party.
Rajoy refused to join a broader debate that took place between Sánchez and the young leaders of the centrist Ciudadanos and left-wing Podemos, whose parties have made significant headway in the polls.
The conservative leader went on to defend his economic record, and said he would prioritise job creation and pensions, while also fighting terrorism and maintaining national unity in the face of an attempted breakaway by politicians in the Catalonia region.
Rajoy, 60, has made economic recovery one of the mainstays of his campaign after Spain in 2014 came out of five years of recession or zero-growth.
But many Spaniards are still not feeling the effects of this recovery and critics say the jobs that have been created are often precarious or badly paid.
Sánchez promised to fight rising inequality and produced graphics and newspaper front pages to argue that the poorest Spanish workers had been ignored, partly at the expense of holding up the country's banking sector.
According to the latest figures, the PP is in first place with 25 percent of projected votes, edging ahead of the PSOE by a 5 point margin. As many as 20 percent of voters remain undecided.