Amsterdam's mayor, who has been gravely ill for several months, has officially stepped down from office, prompting an outpouring of grief and admiration in the Netherlands.

Eberhard Van der Laan, who was diagnosed with metastasised lung cancer, said in a letter on Monday that all options of treatment were exhausted and that he could no longer fulfil his duties.

"Your support has helped me enormously," he said. "It was a great privilege to be the mayor of the prettiest and dearest city in the world."

He went on to thank Amsterdam's citizens for placing their trust in him for the past seven years and for working with him in times of "both agreement and objection".

No-nonsense approach

Van der Laan, considered by many as the most popular Dutch politician in recent years, is known for his no-nonsense approach in local politics, which earned him an ever-increasing fan base in the Netherlands.

Many used #VanderLaan on Twitter to express their support for the Labour Party politician, while Dutch media called the mayor a "folk hero".

It's so sad 😥 our best Amsterdam citizen, mayor #eberhardvanderlaan Eberhard van der Laan is ill and had to decide to stop working. ♥️you pic.twitter.com/0BiK7fNBhq — Ariane Inden (@ArianeInden_me) September 18, 2017

Prime Minister Mark Rutte reacted on Twitter, calling it "very sad news," and expressing "admiration for his courage and openness".

Rutte added that the whole country "empathises with him and his family".

In 2013, Van der Laan, a heavy smoker, was also treated for prostate cancer.

He was given a 7.7 score on his job performance in 2015, a particularly high score, according to daily newspaper De Volkskrant.

On Facebook, people called for a public round of applause at his mayoral residence on Wednesday.

This summer, Van der Laan, 62, appeared in a wide-ranging TV interview that drew over a million viewers, who watched the live broadcast in bars and theatres across the city.

The host of the programme asked what the mayor hoped would be his legacy in the Dutch capital.

"That it remains the kind city it is," he said, while fighting tears.