Madrid (AFP) - British Prime Minister David Cameron warned Friday that if Catalonia breaks away from Spain it will be at the "back of the queue" to get back in the European Union.

Speaking in Madrid, Cameron said he had the same stance on Catalonia's contested drive for independence as he did on Scotland, which a year ago voted against breaking away from Britain.

"We are better off together, stronger together, more prosperous together. We should stay together, whatever situation we're faced with," said Cameron.

The conservative prime minister is meanwhile pushing to renegotiate Britain's membership of the European Union and has promised to hold a referendum on whether it should stay in the bloc.

"If one part of a state secedes from that state, it is no longer part of the European Union and has to take its place at the back of the queue, behind those other countries applying to become members of the EU," Cameron added.

He spoke at a news conference alongside his Spanish counterpart Mariano Rajoy, who fiercely opposes Catalan independence.

Cameron however granted Scotland the right to vote in a referendum on independence -- a move which Rajoy has staunchly resisted for Catalonia.

Pro-independence Catalan leaders want Catalonia's regional election on September 27 to serve as a de facto vote on independence.

Their bid is the most delicate political issue Rajoy faces as he tries to cement Spain's recovery from an economic crisis.

Cameron's trip to Madrid was one of a series of visits to EU leaders to present his demands for reform of the bloc.

He has promised a referendum on Britain's membership by 2017.

Rajoy said his government had a "constructive and flexible" approach to Britain's demands but said it "wishes Britain to stay in the European Union".