Ben Stiller has revealed how he was diagnosed with prostate cancer two years ago after undergoing a "life-saving" routine test.

The Zoolander actor revealed he had the disease for the first time on Tuesday while appearing on The Howard Stern Show. He later published an essay he had written about his ordeal on Medium.

Stiller said the diagnosis of "mid-range aggressive" prostate cancer came "out of the blue" for him after he underwent a routine prostate-specific antigen test in June 2014.

“As my new, world-altering doctor spoke about cell cores and Gleason scores, probabilities of survival, incontinence and impotence, why surgery would be good and what kind would make the most sense, his voice literally faded out like every movie or TV show about a guy being told he had cancer… a classic Walter White movement, except I was me, and noone was filming anything at all,” he writes.

Ben Stiller's Best Films Show all 10 1 /10 Ben Stiller's Best Films Ben Stiller's Best Films Ben Stiller on the set of Along Came Polly. Ben Stiller's Best Films Ben Stiller on the set of Along Came Polly. Ben Stiller's Best Films Ben Stiller on the set of Dodgeball. Ben Stiller's Best Films Ben Stiller starring in the Royal Tenenbaums. Ben Stiller's Best Films Ben Stiller starring in the Royal Tenenbaums. Buena Vista Pictures Ben Stiller's Best Films Ben Stiller on the set of There's Something About Mary. Ben Stiller's Best Films Ben Stiller on the set of There's Something About Mary. Ben Stiller's Best Films Actor Ben Stiller (Greg Focker) goes home with his girlfriend (Teri Polo) to meet her family in Universal Pictures "Meet the Parents." (Photo by Phillip V. Caruso/Universal Studios and Dreamworks LLC/Delivered by Online USA) Getty Images Ben Stiller's Best Films Director Jay Roach with actor Ben Stiller and actress Teri Polo on the set of Universal Pictures "Meet the Parents." (Photo by Phillip V. Caruso/Universal Studios and Dreamworks LLC/Delivered by Online USA) Getty Images Ben Stiller's Best Films Actor Ben Stiller (R) "Greg Focker" meets his girlfriend''s father Robert De Niro (L) "Jack Byrnes" in Universal Pictures "Meet the Parents." (Photo by Phillip V. Caruso/Universal Studios and Dreamworks LLC/Delivered by Online USA) Getty Images

The 50-year-old was declared cancer-free three months later in September 2014 after undergoing a prostatectomy.

An "extremely grateful" Stiller has now decided to speak about his illness in order to encourage men to take the PSA test which he says "saved his life".

"Taking the PSA test saved my life. Literally. That's why I am writing this now [...] If [I] had waited, as the American Cancer Society recommends, until I was 50 I would not have known I had a growing tumour until two years after I got treated. If [I] had followed the US Preventative Services Task Force guidelines, I would have never gotten tested at all and not have known I had cancer until it was way too late to treat successfully."

Stiller said after telling his family, he told his friend and Meet The Parents co-star, actor Robert De Niro, who beat prostate cancer several years ago.

"The first thing I did when I got diagnosed was get on the internet to try to learn,” he said, “I saw De Niro had had it. I called him right away.”

Stiller says he appreciates the issue is a complicated one "but in this imperfect world, I believe the best way to determine a course of action for the most treatable, yet deadly cancer, is to detect it early".