MADRID (Reuters) - Spanish natural gas grid operator Enagas signed on Tuesday an agreement with French counterparts GRTgaz and Terega, setting the terms for developing a planned multi-billion-euro underwater pipeline to carry hydrogen between Spain and France.

The countries are investing in hydrogen as part of Europe's transition to a low-carbon-emission economy. The pipeline, known as BarMar, is expected to cost 2.5 billion euros ($2.67 billion). It is part of a broader plan for hydrogen infrastructure from the Iberian peninsula to France and on to Central Europe, called H2MED.

The agreement sets terms for feasibility studies about the pipeline, conditions for the final investment decision and the creation of a company to potentially develop the project, Enagas said.

Under the deal, the Spanish firm will hold a 50% stake of the company, with GRTGaz and Terega holding 33.3% and 16.7% respectively.

The agreement was also signed by German gas grid operator Open Grid Europe (OGE), which last year joined its French, Spanish and Portuguese peers working to develop the H2MED project.

Enagas also signed an agreement with Portugal's gas grid operator REN strengthening their partnership to develop a green hydrogen pipeline in the Iberian peninsula.

($1 = 0.9347 euros)

(Reporting by Pietro Lombardi; Editing by Rod Nickel)