MADRID (Reuters) - Spain’s minority Socialist government suffered its first major legislative defeat on Tuesday when its main ally in parliament, Podemos, sided with the opposition to throw out its decree on housing, exposing the administration’s weakness.

The Royal Decree, which would have strengthened the rights of tenants renting property, was one of the eight debated on Tuesday in parliament.

The others were approved, including one opening the door for new private operators in Spain’s high-speed rail system, but it was only the fourth time in Spanish democracy that parliament has rejected such a decree.

It was defeated by 243-103 votes, Prime Minister Pedro Sanchez’s first major parliamentary loss since he came to power in June.

Royal Decrees are approved directly by government but need to be ratified by a simple majority vote in parliament.

It is a quicker procedure than the standard parliamentary process for approval of legislation, and governments usually strive to guarantee support beforehand to avoid humiliating defeats.

The Socialists hold about a quarter of parliament seats and Sanchez needs the backing of Podemos, Catalan nationalists and other small parties to pass legislation.

Failure by parliament to approve the government’s 2019 budget proposal, which faces its first vote next month, could prompt a snap election before the scheduled general ballot in 2020.

Home-building, buoyed by foreign investment, is thriving again in Spain 11 years after a property bubble burst to trigger an economic slump, and rental prices have been rising in bigger cities.

The anti-austerity Podemos decided not to support the decree because it did not include caps on rental prices, as they had agreed with the Socialists.

“To vote against this Royal Decree is an act of responsibility ... an act to demand brave measures that truly start to guarantee housing rights to all citizens,” Lucia Martin, a lawmaker from En Comu Podem, the Catalan branch of Podemos, said during the debate.

She said talks with the government to reach a new housing deal would continue and that Podemos was not seeking to weaken their fragile parliamentary alliance with the Socialists.

Podemos is going through a complicated moment after one of its founders, Inigo Errejon, gave up his seat in parliament on Monday. The party has lost support in recent polls months before regional and municipal elections.