When Kumail Nanjiani arrived at Grinnell College from Pakistan nearly 20 years ago, he was a devout Muslim who had never romantically touched a girl and was going to get a degree that would guarantee him a job.

“By the time I graduated, I was basically a Rastafarian with a white American girlfriend and a philosophy degree,” the comedian and actor told 390 graduating seniors Monday during the 171-year-old college’s commencement.

Nanjiani had also never experienced stand-up comedy until his fellow classmates at Grinnell showed him a video of Jerry Seinfeld. He later worked up enough nerve to do his own set at Bob’s Underground on campus.

"Before America was my home, Iowa was my home," he said.

Graduating in 2001 with degrees in both philosophy and computer science – “because although I had changed, my parents hadn’t” – Nanjiani moved to Chicago, got a computer science job through his Grinnell connections and spent most of his nights honing his stand-up skills.

After averaging about four hours of sleep a night for the next five years, he went on to New York City to become a professional comedian and earned spots on “The Colbert Report,” “Key and Peele,” “Portlandia” and “Silicon Valley.” His first movie, “The Big Sick” – which he co-wrote with his wife, Emily Gordon – is scheduled for wide release this summer.

Sundance: Kumail Nanjiani on his breakout 'Big Sick' and Trump-era comedy

But none of that success — whether in life or love — seemed a certainty at Nanjiani’s graduation ceremony back in 2001.

“Sixteen years ago almost to the day, I sat where you are sitting, trying to stay awake, while a very smart man said some very smart things – I think,” he said. “I cannot be sure they were smart, because I couldn’t focus on anything but the gaping maw of uncertainty facing me at that moment.”

Nanjiani said he had no suggestions on what do do about that "gaping maw,” but he did offer today's graduates a few standard pieces of advice on what has worked for him over the years.

Find something that you like doing – something that satisfies you – and do it for just that day. “I never thought (about the) big picture,” he said. “That would have overwhelming. So what I’m saying is, you can go slow. Allow your dreams and goals to change, but live an intentional life.”

“I never thought (about the) big picture,” he said. “That would have overwhelming. So what I’m saying is, you can go slow. Allow your dreams and goals to change, but live an intentional life.” Be okay with failure. “Nobody is paying attention to your failure,” he said. “The world is full of people failing. People are failing all around you. Failure is boring. Your failure will not be so spectacular that people will write articles about your failure or even remember your failure.”

“Nobody is paying attention to your failure,” he said. “The world is full of people failing. People are failing all around you. Failure is boring. Your failure will not be so spectacular that people will write articles about your failure or even remember your failure.” Populate your life with people different than you. “Being a fish out of water is tough, but that’s how you evolve," he said. "I think that scientifically accurate, I don’t know. I had a liberal arts education.”

In the biggest laugh line of his speech, Nanjiani also offered some non-standard advice based on his experience falling in love with and marrying a woman so very different than the future spouse his Pakistani parents imagined for him.

“Seeing her white Southern family and my Pakistani family gather, it was beautiful," he said. "I don’t have words. So here’s another concrete piece of advice: have sex with an immigrant. We’re going through a tough time. And it would be really great for morale. And it would make sure that you will definitely be on the right side of history.”

Nanjiani grew serious, however, in offering a shout out to the families of the 50 graduating international students who had traveled to the U.S. for this event.

“As nervous as you were to get through customs and immigration, I hope that you were just as proud to watch your children walk across the stage, and I hope that today, you see the America that we love,” he said.

He also took issue with a recent tweet made by U.S. Rep. Steve King, R-Iowa, claiming that civilization can’t be restored “with somebody else’s babies.”

“That is not the Iowa I know," Nanjiani said. "The Iowa I know understands that there is no such thing as somebody else’s babies. ... This was the second place in my life that felt like I was home — different, weird, but not strange.”

After his speech, Nanjiani was given an honorary doctorate of humane letters “for pursuing comedy that is both incisive and deeply heartfelt and for succeeding at this work at the very highest levels.”

He texted his parents during the ceremony to let them know that they finally have a doctor for a son.

Editor's note: An earlier version of this story misspelled the name of Nanjiani's wife, Emily Gordon.

Reach Jeff Charis-Carlson at jcharisc@press-citizen.com or 319-887-5435. Follow him on Twitter at @JeffCharis.