LONDON - Britain's Thames Water secured court approval for a 3 billion pound ($3.8 billion) debt lifeline on Tuesday, warding off nationalisation for the country's biggest water supplier in the short term and giving it time to sort out its finances.

The government has been on standby to put Thames Water, which is struggling with 18 billion pounds in debt, into special administration, a form of temporary nationalisation aimed at keeping the taps on in the event of financial collapse.

The utility is at the centre of a public backlash against the country's privatised water industry, blamed for polluting rivers with sewage. The government wants Thames to avoid administration and is focusing its efforts on reforming the sector.

The debt lifeline, provided by senior creditors and approved by the judge, will give Thames an initial 1.5 billion pounds plus the potential for a further 1.5 billion, extending its funding until May 2026. Without the approval the company said it would have run out of cash in six weeks.

The new debt package was, however, controversial. A group of lower-ranked creditors opposed it, calling its 9.75% interest rate too costly.

With the rescue package in place, Thames Water, which has 16 million customers, still must overcome multiple challenges to ensure it can survive beyond 2026.

It needs to raise over 3 billion pounds in new equity as well as restructure its debts, while at the same time improving its infrastructure and environmental performance to avoid paying millions in fines.

Complicating the picture for any would-be investors is the price Thames Water is permitted to charge customers over the next five years.

The regulator has said the company can hike bills by 35% over that time, below the 53% rise it says it needs. It lodged an appeal with Britain's Competition and Markets Authority on February 14 in an effort to get improved terms.

The rescue package was provided by a group of Thames Water's senior creditors including Abrdn, Apollo Global Management, Elliott Investment Management, Invesco, M&G and PIMCO.

($1 = 0.7931 pounds)

(Reporting by Sam Tobin and Sarah Young in London and Yadarisa Shabong in Bengaluru; Editing by Mrigank Dhaniwala and Kate Holton)