MADRID, Nov 6 (Reuters) - Extending Spain's windfall tax on large energy companies would put at risk 16.5 billion euros ($17.7 billion) in investments linked to the energy transition, a lobby group representing the country's main oil companies warned on Monday.

This is the latest salvo against the potential extension of the levy, included in a coalition agreement between the Socialist Party of acting Prime Minister Pedro Sanchez and the hard-left Sumar, which are seeking to form a government.

Last December, the government imposed a two-year, 1.2% levy on energy companies with a turnover of at least 1 billion euros.

Oil major Repsol has already frozen investment plans for a hydrogen plant in northern Spain. Last week, Jose Bogas, the chief executive of power utility Endesa, criticised the tax as "discriminatory and unjustified".

"Maintaining this tax puts at risk 16.5 billion euros in investments for the energy transition," the AOP lobby group said, arguing such investments "would be exposed to fiscal and regulatory uncertainty".

The Spanish unit of global oil major BP, as well as Spanish firms Cepsa and Repsol, are among the companies represented by the group.

Repsol is among the companies that have challenged the tax in courts, with Spain's High Court in February rejecting a Repsol request for an injunction against it.

($1 = 0.9308 euros) (Reporting by Pietro Lombardi Editing by Mark Potter)