Click to email this to a friend (Opens in new window)

Janeane Garofalo was married for 20 years and didn’t even know it, until she needed to get divorced Saturday.

She explained at a New York Comedy Festival reunion for “The Ben Stiller Show” that she married a writer on the series — Rob Cohen, who went on to produce “The Big Bang Theory” — in Las Vegas as a joke in the 1990s, and didn’t realize the nuptials had stuck.

“Rob and I got married, for real, which we had to have a notary dissolve not 30 minutes before we got here tonight,” Garofalo said. “We were married for 20 years until this evening.”

She added, “We got married drunk in Vegas . . . We dated for a year, and we got married at a drive-through chapel in a cab. [We thought] you have to go down to the courthouse and sign papers and stuff, so who knew? We were married, and apparently now that [Rob] is getting married for real, his lawyer dug up something.”

We’re told Cohen, whose credits include HBO’s “The Life & Times of Tim,” is engaged to Jill Leiderman, a producer on “Jimmy Kimmel Live.” While Wikipedia had described Garofalo and Cohen as married, they apparently thought it was all part of the two-decade joke.

At the reunion, called “Oddly Familiar,” at the Paley Center for Media, director Judd Apatow asked the unwitting exes Garofalo and Cohen if either had benefitted financially from the split, which Garofalo said was notarized at a TD Bank in Midtown.

“I’m gonna get all of that ‘Reality Bites’ money!” Cohen joked, referring to Garofalo’s 1994 Ethan Hawke–Winona Ryder Generation X drama, which grossed $21 million.

Recalling their long-ago dating days, Garofalo quipped, “I’m sure I was terrible,” to which Cohen responded, “I will confirm that.” Garofalo added she no longer drinks.

Also at the reunion panel, sponsored by Svedka vodka, were Stiller, Andy Dick and “Breaking Bad” star Bob Odenkirk, who beamed in via video. Reps for Garofalo, Cohen and Leiderman didn’t get back to us.