"Last Comic Standing" finalist and outspoken weed advocate Ralphie May is finally calling it quits on the sticky icky -- telling TMZ, smoking marijuana nearly killed him last year ... so he's giving it up for good.

May tells us, he was diagnosed with walking pneumonia before taking a cruise last November -- but the condition quickly got worse ... and before long, he was holed up in the boat's infirmary with a life-threatening lung infection.

May tells us, "If I hadn't been a 20-year weed smoker, it wouldn't have been as bad."

You'll recall -- May was detained in a Guam airport back in 2010 for weed possession after the comic decided to pet a drug-sniffing dog. Not his brightest moment.