The 62-year-old conservative leader has vowed to stop Catalonia's pro-independence regional government from going ahead Sunday with a secession plebiscite, which has been ruled unconstitutional by Spain's Constitutional court.
Acting on the orders of the authorities in Madrid, Spanish riot police, some firing rubber bullets, used force to “neutralise” polling stations by seizing ballot boxes and ballots.
Head of the Popular Party (PP) since 2004 and of the government since 2011, Rajoy has fended off challenges from rivals in his own party and opposition adversaries, and managed to remain in power even after his formation lost its absolute majority in parliament in 2015.
- AS-IT-HAPPENED Clashes at polling stations as Catalonia struggles to hold vote for independence
- 10 facts on Catalan President and pro-independence leader Carles Puigdemont
- INTERVIEW Catalan independence: 'Politicians are acting like children with a box of matches'
His reputation as a survivor was cemented in 2005 when he emerged from a helicopter crash with just a broken finger.
“You have elephant skin,” German Chancellor Angela Merkel told him jokingly last November, a compliment that was splashed across the Spanish press.
But Rajoy is now trapped by Catalonia's drive for independence, an issue which he skillfully exploited while in the opposition.
Born in 1955 in Santiago de Compostela in the northwestern region of Galicia, Rajoy, a lawyer by training, was one of the fiercest opponents of an autonomy charter agreed by Catalonia in 2006 with the Socialist Spanish government at the time.
He led a campaign to gather four million signatures for a petition opposing the charter, which was approved by the Spanish parliament and granted Catalonia greater powers and recognised it as a “nation”.
Spain's Constitutional Court in 2010 struck down parts of the charter in response to a legal appeal filed by Rajoy's PP.
The ruling prompted mass protests in Catalonia, a wealthy region whose roughly 7.5 million residents are proud of their distinct language and culture, and a surge in support for independence.
When Rajoy took power in 2011 Spain was in the midst of a severe economic crisis, and he refused to listen to the demands for greater fiscal autonomy by the Catalan regional government.
Catalonia then began to demand the right to hold an independence referendum, which he repeatedly rejected, arguing that it would violate Spain's constitution.
His detractors accuse him of intransigence and of “manufacturing separatists”.
And having initially castigated Catalonia's separatist leaders, he has recently tried to win over Catalans with pledges of more investment, while emphasising Spaniards' love for the region following the jihadist attacks in and around Barcelona in August that killed 16 people.
But these efforts have largely been shrugged off in the streets of Catalonia.
A father of two, Rajoy turned to politics at a young age, joining the Popular Alliance, the party founded by former ministers in the government of Francisco Franco which later became the PP.
After becoming leader of the PP in 2004, Rajoy went on to lose two general elections to the Socialists before voters finally handed him the premiership in 2011 as Spain suffered the ravages of the financial crisis.
When he lost his majority in parliament in a general election in December 2015, Rajoy found himself without allies to form a coalition.
He waited while other parties tried but failed to form a government, and new elections were called in June 2016 which saw his PP once again win the most seats but fall short of a majority.
He formed a minority government with the backing of the smaller centrist Ciudadanos party, which was formed in Catalonia to oppose independence.
Rajoy credits his unpopular austerity measures for lifting Spain out of its economic malaise and allowing Spain to avoid an international bailout.
The government predicts the Spanish economy will expand 3.1 percent this year and unemployment is falling, though most new jobs are temporary and low-paying positions.
Analysts say a string of corruption scandals that have tainted the PP have prevented it from benefiting more from Spain's economic rebound.
Rajoy has long insisted that the scandals are isolated cases he knew nothing about.
“It's obvious that he is an uncharismatic leader but he has perfect control of time and incredible knowledge of the decision-making process,” said Narciso Michavila, an expert in electoral analysis who has advised Rajoy.