Scotland would immediately be ejected from the European Union were it to vote for independence in the forthcoming referendum, according to the Spanish prime minister, Mariano Rajoy, in comments clearly directed at Catalan nationalists who want the right to hold their own vote on secession from Spain.

"This is a fact, it's neither a value judgment nor an opinion, it's simply a fact. If part of a country integrated into the European Union leaves that country, then logically it would be outside the European Union, not because I say so, but because that's what the treaties say," said Rajoy, in an interview with the Guardian and partner newspapers from Spain, Germany, Italy and France.

The territorial integrity of Spain is a key issue for Rajoy's rightwing government, and his renewed comments on Scotland are a proxy for his views on the potential breakaway of Catalonia. "[Scotland] would have to join the queue [to enter the EU]," he said. But Rajoy would not commit himself on whether he would use Spain's veto, as an EU member country, to prevent it from rejoining. In the case of Scotland voting for independence "we would be in a different story. Let's not get ahead of ourselves," he said.

Covering his bases in case of a yes vote, Rajoy was also keen to argue that Scots and Catalans do not have a shared history or trajectory. "The cases of Scotland and Catalonia are very different. The UK does not have a written constitution. Furthermore, if I'm not wrong, the right to self-determination has only been recognised in three constitutions, those of the Soviet Union, Yugoslavia, and Ethiopia."

The question of Catalonia's independence has become an increasingly hot topic in Spain, with Catalan leaders demanding the right to a vote on the matter, something which Rajoy argues would be illegal under Spanish law.

"As head of the government I have certain obligations, including of course, ensuring that the law is followed. That is to say, I cannot authorise a referendum in Catalonia. Not only do I not want to, but on top of that, I cannot," he said.

Although Rajoy generally adopts a more conciliatory tone than some of his ministers, tensions have become so high between Madrid and Barcelona that any remarks will go down badly with Catalan nationalists. Asked how he would try to win back "hearts and minds" in Catalonia, he raised the issue of the financing of the region's debt, saying that his government had already provided it with €29bn worth of assistance. "We're going through difficult times … but I am sure that the situation will turn around," he said.

Rajoy arguesthat calls for Catalan independence go against the winds of change across the world.

"We are talking about the banking union or fiscal union in Europe, we're talking about a single European market … Look at all these movements for regional integration, and all of the treaties of free trade that are being negotiated. These are important events. That is to say, I believe we need to walk in the same direction … and that is towards greater integration, not against it," he said.

Catalonia is not the only question of self-determination on Rajoy's plate. This summer saw a war of words between Madrid and London over the British colonial territory of Gibraltar, which ostensibly started over what Spain argues was an illegal underwater reef in contested waters, but has developed into an increasingly unseemly public row.

Aware of his audience, Rajoy was keen to play down any potential conflict between the Spanish and British governments. "Relations between Spain and the UK are fantastic, as they are between Mr Cameron and me," he said.

Rajoy argued that on one level the dispute was one of decolonisation, about which Madrid has made numerous calls on the UN to act, but that now "it was more about decisions taken by the Gibraltar authorities, which affect questions such as environmental and fiscal laws. We're not talking about sovereignty, but about fulfilling the norms of the European Union."

Rajoy raised other long-standing complaints of Madrid's, namely the smuggling of tobacco into Spain and the number of offshore businesses based in Gibraltar.

Many observers believe that Rajoy is happy to stoke the debate over Gibraltar as a distraction from the economic crisis in Spain, and the ongoing corruption scandals surrounding his party, but on this occasion, he was keen to appear considered. "I hope this can all be resolved intelligently and to the satisfaction of all sides," he said.