The actor who played Robbie Rotten on the popular kid's show "LazyTown" has died after a long battle with cancer ... TMZ has learned.

A spokesperson for the family of Stefan Karl Stefansson tells us the actor died Tuesday surrounded by friends and family. We're told Stefan had battled bile duct cancer for two years before his death.

The 43-year-old from Iceland was a fixture on "LazyTown" over the course of 10 years ... starring alongside Julianna Mauriello, who played Stephanie. Stefansson's last episode on the show was its finale in 2014.

Waiting for your permission to load the Instagram Media.

Stefansson was first diagnosed with cancer in 2016 but after surgery it appeared he was on the path to recovery. However, it returned in 2018 and was inoperable.

In a statement in March, Stefansson said, "It's not until they tell you you're going to die soon that you realize how short life is. Time is the most valuable thing in life because it never comes back. And whether you spend it in the arms of a loved one or alone in a prison-cell, life is what you make of it. Dream big."

He is survived by his wife and 4 children.