Spanish politics has been plunged into disarray since Catalonia held an independence referendum a week ago. Catalan leaders say the people voted overwhelmingly to split, but Madrid has declared the vote illegal.
Catalonia, of which Barcelona is the capital, is Spain's wealthiest region and has its own language and distinct culture. It has had a strong independence movement for decades and has already won sweeping powers to govern itself as an autonomous region within Spain.
"We are going to stop independence from happening. On that, I can tell you with absolute frankness, that it will not happen. It is evident that we will take whatever decision that we are permitted to by law, in view of how things are unfolding," Rajoy told the El Pais newspaper in an interview.
Asked if this would include using Article 155 of the Constitution, the legal mechanism needed to suspend Catalonia's autonomy, Rajoy said: "I am not absolutely ruling out anything that the law allows. I would like to do it at the right time ... that it is more important at the moment.
"The ideal scenario would be that there were no need for drastic solutions, but for that there would need to be rectifications."
He added: "I want to say something with absolute clarity -- while the threat of independence is in the political landscape, it will be very difficult for the government to not take these decisions."
Rajoy also called on "moderate" Catalans to "come back" and move away from "extremists, radicals" as well as the Popular Unity Candidacy party (CUP) spearheading the movement. It is the first time he has reached out to the Catalan people since the referendum.
Catalan leader Carles Puigdemont has threatened to declare independence early next week, and hundreds of thousands of Catalan protesters marched in favor of splitting from Spain
A large crowd with Spanish flags, however, began gathering in central Barcelona on Sunday for a pro-unity march.
Rajoy also slammed the independence bid as part of a current wave of populism sweeping across Europe, pointing to the rise of far-right parties in France, Germany and the UK.
"Another form of populism, without doubt, is this nationalist populism that we are experiencing, which violates the fundamental principles of the European Union, goes against the rule of law, against law enforcement, and so it is a problem also from Europe.
"And that's why Europeans have stuck up for us and all the governments have supported the Spanish constitution and the upholding of the law."
The past week in Catalonia has been nothing short of chaotic. Madrid responded to the vote with force, sending thousands of police to the region to shut down the vote.
Images of police restraining elderly women and pulling voters out of polling booths by the hair have caused outrage around the world and appear to have fueled anti-Madrid sentiment in Catalonia itself.