By Francesco Guarascio

BRUSSELS (Reuters) - EU pension funds will have to include environmental risks in their investment strategies, under a law passed on Thursday, that ecologists hope will encourage money to flow out of fossil fuels and into greener sectors.

A large majority in the European Parliament backed the law that requires managers of retirement funds to take into account the "environmental, social and governance risks" of their investments.

The vote confirms a deal already reached with EU governments so its final approval is now a formality.

It comes as the European Union looks at other measures to reduce long-term systemic risks linked to climate change, extreme weather or volatile energy prices. Finance ministers have discussed the possibility of carbon stress tests for financial firms.

Under the new law, the potential negative effects of climate change or political factors on retirement funds will get the same level of attention as liquidity, operational or asset risks.

"This is a big success for the promotion of investments in sustainable products," German Greens lawmaker Sven Giegold said, adding that the law "paves the way for the introduction of fossil divestment by European pension funds".

The pensions industry holds in Europe assets for a value of about 3 trillion euros ($3.17 trillion) on behalf of around 75 million people.

Conservation group WWF said: "This vote represents a landmark moment for responsible investment in Europe."

"It represents the strongest and clearest requirement on such an issue yet seen in any EU text."

The law, which overhauls existing legislation, aims at making the sector safer, introducing a new set of reporting and risk-management requirements.

It also encourages long-term investment and seeks to facilitate funds' ability to operate across European borders, removing legal barriers and lowering costs.

PensionsEurope, the group representing pension funds, said the law would help a sound development of the industry and praised the fact that it did not add new capital requirements.

(Editing by Robin Pomeroy)