Barack Obama collected Spider-Man comics as a child, so Marvel Comics wanted to give him a "shout-out back" by featuring him in a bonus story, said Joe Quesada, Marvel's editor-in-chief.
"How great is that? The commander in chief to be is actually a nerd in chief," Quesada said. "It was really, really cool to see that we had a geek in the White House. We're all thrilled with that."
The comic starts with Spider-Man's alter-ego Peter Parker taking photographs at the inauguration, before spotting two identical Obamas.
Parker decides "the future president's gonna need Spider-Man," and springs into action, using basketball to determine the real Obama and punching out the impostor.
Obama thanks him with a fist-bump.
Marvel comics have featured most presidents, but generally in walk-on roles, Quesada said.
"I think President Nixon might have appeared on the cover, but not in a good way," he said.
Obama has said that as a child, he collected Spider-Man and Conan the Barbarian comic books. His Senate Web site used to have a photo of him posing in front of a Superman statue.
The Obama story is a bonus in Marvel Comic's Amazing Spider-Man #583, available in comic book shops nationwide on Jan. 14 for $3.99 and is expected to sell out, with half the covers devoted to Obama.