LOS ANGELES -- Comedian Lloyd Ahlquist steps onto the stage, girded for battle. Wearing the uniform of a Soviet officer, with medals dripping from his chest, he channels dictator Joseph Stalin and prepares to deliver a rhyming smackdown on Russia's mad monk, Grigori Rasputin.
The cameras roll, the music playback reverberates through the Culver City, Calif., studio -- then an unexpected glitch halts production on "Epic Rap Battles of History's" second-season finale. Mr. Ahlquist's thick mustache is obscuring his mouth, making it difficult to see him snarl such insults as "All your wizard friends: shot! Anyone who sold you pirogi: shot!"
Mr. Ahlquist, director Dave McCary and a makeup artist consult: Should they compromise authenticity and give Stalin's mustache a trim? After a 10-minute discussion, co-creator Peter Shukoff enters the studio wearing Rasputin's flowing black garment and a long scraggly beard. He says the mustache "looks great" -- it's the overcompensation that's the problem.
"I've been trying to keep my mouth open a little bit, and jut my jaw out," Mr. Ahlquist explains. "I just don't want to look too much like Wario."
The mustache would retain its Nintendo antihero glory.
This fanatical attention to detail pays off with the audience: The Rasputin versus Stalin rap battle has attracted nearly 12 million views since premiering on YouTube three weeks ago.
The series' YouTube channel has exposed millions of fans -- three-quarters of them males ages 13 to 34 -- to F-bomb-laced altercations between Adam and Eve or Justin Bieber and Beethoven, jousting in a format born among rappers on the streets of New York City in the 1970s.
Reputations were made on the sidewalks of Harlem -- and occasionally preserved on audio cassette tapes or hand-held camcorders.
Former Def Jam president Joie Manda remembers traveling to Harlem in 2003 to witness the verbal sparring match between rappers Jae Millz and Murda Mook. Only a few hundred people knew about the contest of wits, rhymes and raw humor.
"It was a lot like 'Fight Club,' " Mr. Manda said. "Let's meet at 125th Street at 4 o'clock and see who's better."
Mr. Shukoff recalls the eureka moment when he suggested adapting a segment of Mr. Ahlquist's improv comedy show for the Internet. They experimented with taking old-school rap battles in a new direction, freestyling an exchange between "Back to the Future" star Michael J. Fox and Chucky, the movie doll possessed with the soul of a serial killer.
"It was totally stupid, but you could tell it was cool -- and infinitely refillable."
The duo met in a freestyle rap session on Mr. Ahlquist's front porch in Chicago.
Mr. Shukoff was hungry for fresh material when, in 2010, Mr. Ahlquist described the rap battle segment in his improv show, Check One Two.
Mr. Shukoff was convinced that Internet audiences would thrill to the random collisions of characters real and fictional who would only ever meet "at a party in transdimensional space."
In what became the first installment, John Lennon threatened Bill O'Reilly, "I'll take Maxwell's Silver Hammer and give you a lobotomy," while O'Reilly retorted, "You longhair living in your yellow submarine, you're about to get sunk by the right-wing political machine." The video has gone on to reach 26.7 million views.
Thirty-two videos followed over the course of three years, including one in which rapper Snoop Dogg appeared as Moses dissing Santa Claus.
"Snoop rapped every word that we wrote," an awestruck Mr. Shukoff said. "He Snoopified it and made it awesome."
The two comedians' work popularizes the once-underground game of rap battles, in which two participants hurl invective at each other in a progressive series of put-downs, known as "the Dozens," that have deep roots in African culture.
The phenomenon began creeping into the cultural mainstream with rapper Eminem's freestyle battles in the 2002 movie "8 Mile" and the "Freestyle Friday" videos on BET's video countdown show "106 & Park."
Now, the borderless reach of the Internet has given these competitions another boost. YouTube is home to more than 60 rap battle channels, including the newly launched paid channel Rap Battle Network, that have amassed more than 2 billion views.
"Rap battles come very much out of that [tradition] where different rappers go back and forth, and who has the best skills is decided by the crowd," said Malik Ducard, YouTube's director of content partnerships. "It existed before, but it found a real home on YouTube because it's not anywhere that is super accessible -- unless you're really there."
"Epic Rap Battles of History" -- whose channel now boasts more subscribers than Justin Bieber, Taylor Swift or Skrillex -- has achieved a broad audience by departing from one aspect of the traditional rap battles, in which the keen-eyed observer lambastes an opponent's appearance, reputation or background. Instead, its sketches mine humor from the oddball matchups and funny outfits, and in lampooning the foibles of well-known characters.
"That's the most commercial side of it," Mr. Manda said. "That's probably the softer side -- it's a lot safer."
Mr. Ahlquist and Mr. Shukoff pride themselves on authenticity -- their sound mixer, Jose "Choco" Reynoso, has worked with such mainstream rap acts as the Wu-Tang Clan.
"One thing that we both agreed on was that we wanted to make good rap music. We didn't want the series to be a parody," said Mr. Ahlquist, who is known to fans as EpicLloyd. "We wanted it to be an honest take on what an actual battle would be."
"That's where we lucked out," said Mr. Shukoff, whose stage name is Nice Peter. "Lloyd was a comedian for a living, but he did rap music as a passion, a hobby. There were no jokes in his raps, back in the day. And I was a songwriter who found the easiest way to entertain a hostile crowd was to use some humor in my songs."
The collaboration succeeds, in part, because the two complement each other creatively. Mr. Shukoff, the self-described computer nerd, is in touch with the videos that resonate on YouTube, while Mr. Ahlquist draws from the timing of live stage performance and the sharp tongue of a rapper.
"That's what balances us out," Mr. Shukoff said. "Because if I had free rein, I would become too nerdy with it. It would lose heart. It would lose grit."