Mad Men
Don Draper (Jon Hamm, pictured) came up with the famous "I'd Like to Buy the World a Coke" ad in the "Mad Men" series finale. AMC

The “I’d Like to Buy the World a Coke” ad ending to May’s “Mad Men” series finale took many fans by surprise, but the Coca-Cola conclusion was a long time in the making. Jon Hamm, who played Don Draper on the acclaimed AMC series, appeared on “Jimmy Kimmel Live!” Tuesday night where he revealed that “Mad Men” creator Matthew Weiner had a few obstacles to hurdle to clear the iconic ad for the show.

While discussing the much talked about finale, Hamm told host Jimmy Kimmel that the decision to include the famous Coke ad in the episode did not happen overnight.

“Matthew Weiner had seized on this idea in Season 4,” said Hamm, explaining that Weiner did not get the soda company’s permission right away. “There was a couple years process in clearing that with Coca-Cola.” When asked what would have happened if Coke refused, Hamm joked, “You’re like, ‘All right, we’ll call it Coca… Cona.’”

Hamm also teased that a funnier ending for “Mad Men” would have been his character, who ended the series in meditation, opening his eyes at the camera and yelling, “What’s up,” in reference to the classic Budweiser ad campaign.

Watch Hamm’s exchange with Kimmel below:

Lucky for Weiner, Hamm, and everyone else involved with “Mad Men,” Coca-Cola did give the show permission to reappropriate the ad as a Don Draper original. According to Entertainment Weekly, Coke did not even charge AMC for the rights!

There had been debate among fans as to whether the final scene implied that Don Draper had gone on to create the ad after the credits. Weiner set the record straight in May, confirming that, yes, in the world of the show Don had penned the famous campaign.

"In the abstract, I did think, why not end this show with the greatest commercial ever made? In terms of what it means to people and everything, I am not ambiguity for ambiguity's sake,” said Weiner, according to the Hollywood Reporter. “But it was nice to have your cake and eat it too, in terms of what is advertising, who is Don and what is that thing?

Watch the final scene of “Mad Men,” including the Coke ad, below: