His visit to Barcelona comes one day after Catalonia's battered independence movement staged a massive protest in the city, demanding the release of jailed leaders and recognition of a separate Catalan Republic.
Rajoy is expected to make a campaign appearance in Barcelona for his conservative Popular Party, ahead of regional elections next month.
Spain's central government imposed direct rule on Catalonia immediately after its regional parliament voted for independence Oct. 27. It arrested dozens of secessionist politicians, causing the head of the regional government, Carles Puigdemont, to flee to Belgium.
Eight members of the dissolved regional government and two prominent activists are in jail.
Those imprisoned without bail include Catalan Vice President Oriol Junqueras.
The head of the regional parliament who presided over the independence vote, Carmen Forcadell, was released from prison Friday after retracting her secessionist stance before Spanish judges. She said the independence vote had been "symbolic."
A bail of $165,000 was posted for her by the pro-independence Catalan National Assembly (ANC), one the main organizers of Saturday's march.
Protesters hold the lights of their mobile phones during a demonstration called by pro-independence associations asking for the release of jailed Catalan activists and leaders, in Barcelona, Spain, Nov. 11, 2017.
Even though Madrid's virtual decapitation of the Catalonian secessionist leadership has left the independence movement badly split, the ANC and another organization called Omnium Cultural managed to turn out more than 700,000 protesters Saturday, according to Barcelona's local police. Other estimates put the figure between 500,000 to 600,000.
"We must not allow ourselves to be scared or coerced by those who want to cut our liberties and annihilate and humiliate our institutions," Puigdemont said in a prerecorded video from Brussels, which was played on a large screen before the crowds.
"We never expected the government to react quite so hard," ANC activist Doria Asina told VOA. "We calculated that the chances of the Madrid imprisoning our leaders was no more than 10 percent. It's all come as something of a shock."
The secessionist coalition itself also is fractured.
Heads of the separatist PEdeCAT, Catalan Republican Left and the extreme leftist CUP have traveled to Brussels for meetings with Puigdemont, who is trying to cobble together a united front for independence to contest the Dec. 21 regional elections called by Prime Minister Rajoy.
Spanish government analysts fear that a disconnect could develop between the politicians and radical activists, who may opt for more violent tactics.