New York City is seeking to lead the assault on climate change and the Trump administration with a plan to divest $5bn from fossil fuels and sue the world’s most powerful oil companies over their contribution to dangerous global warming.

City officials have set a goal of divesting New York’s $189bn pension funds from fossil fuel companies within five years in what they say would be “among the most significant divestment efforts in the world to date”. Currently, New York City’s five pension funds have about $5bn in fossil fuel investments. New York state has already announced it is exploring how to divest from fossil fuels.

“New York City is standing up for future generations by becoming the first major US city to divest our pension funds from fossil fuels,” said Bill de Blasio, New York’s mayor.

“At the same time, we’re bringing the fight against climate change straight to the fossil fuel companies that knew about its effects and intentionally misled the public to protect their profits. As climate change continues to worsen, it’s up to the fossil fuel companies whose greed put us in this position to shoulder the cost of making New York safer and more resilient.”

De Blasio said that the city is taking the five fossil fuel firms – BP, Exxon Mobil, Chevron, ConocoPhillips and Shell – to federal court due to their contribution to climate change.

Court documents state that New York has suffered from flooding and erosion due to climate change and because of looming future threats it is seeking to “shift the costs of protecting the city from climate change impacts back on to the companies that have done nearly all they could to create this existential threat”.

The court filing claims that just 100 fossil fuel producers are responsible for nearly two-thirds of all greenhouse gas emissions since the industrial revolution, with the five targeted companies the largest contributors.

The case will also point to evidence that firms such as Exxon knew of the impact of climate change for decades, only to downplay and even deny this in public. New York’s attorney general, Eric Schneiderman, is investigating Exxon over this alleged deception.

Q&A What is divestment? Show Divestment is the opposite of investment. It's the shifting of stocks, bonds or funds from certain businesses or sectors. Individual people invest in various ways to generate money, but large institutions such as cities, universities and religious organizations do this on a huge scale. Traditionally, fund managers put together investment portfolios that will provide the best returns for these institutions, regardless of where the money is invested. The divestment movement, primarily consisting of climate activists, is urging private and public institutions to rid their portfolios of all oil, gas and coal stocks to send a financial and ethical message that fossil fuels are harmful and shouldn't be tolerated. So far, it's estimated that funds totalling $6tn have committed to divesting from fossil fuels. Activists hope this momentum will deprive fossil fuels of a social license, similar to tobacco, and help accelerate the deployment of cleaner energy, such as wind and solar. Photograph: Bloomberg

New York was badly rattled by Hurricane Sandy in 2012 and faces costs escalating into the tens of billions of dollars in order to protect low-lying areas such as lower Manhattan and the area around JFK airport from being inundated by further severe storms fueled by rising sea levels and atmospheric warming. De Blasio’s office said climate change is “perhaps the toughest challenge New York City will face in the coming decades”.

New York’s lawsuit echoes a similar effort on the west coast, where two California counties and a city are suing 37 fossil fuel companies for knowingly emitting dangerous levels of greenhouse gases. One of those firms, Exxon, has complained that it has been targeted by a “collection of special interests and opportunistic politicians” as part of a “conspiracy” to force the company to comply with various political objectives.

The legal action and the divestment draw perhaps the starkest dividing line yet between New York and the Trump administration on climate change. Under Trump, the federal government has attempted the withdraw the US from the Paris climate accords, tear up Barack Obama’s signature climate policies and open up vast areas of America’s land and waters to coal, oil and gas interests.

De Blasio and the city comptroller, Scott Stringer, have come under pressure for several years from activists to rid New York’s pension funds of any link to fossil fuels, with some environmentalists claiming the city has been too slow to use its clout to tackle climate change.

Stringer admitted the divestment will be “complex” and will take some time but said the city’s pension funds could promote sustainability while also protecting the retirement of teachers, police officers and other city workers.

“New York City today becomes a capital of the fight against climate change on this planet,” said Bill McKibben, co-founder of climate group 350.org.

“With its communities exceptionally vulnerable to a rising sea, the city is showing the spirit for which it’s famous – it’s not pretending that working with the fossil fuel companies will somehow save the day, but instead standing up to them, in the financial markets and in court.”

Christiana Figueres, former UN climate chief and architect of the Paris climate agreement, added: “The exponential transition toward a fossil-fuel-free economy is unstoppable and local governments have a critical role to play. There is no time to lose.

“It’s therefore extremely encouraging to see NYC step up today.”

New York joins cities such as Washington DC and Cape Town in divesting, along with universities such as Stanford in California and Oxford in the UK. The Rockefeller Brothers Fund, notable for its links to the past oil wealth of John D Rockefeller, has also sought to divest.