The conventional wisdom is that he was once for marriage equality and then reversed himself for political reasons. The root of this is a questionnaire his campaign filled out for the gay paper "Outlines" in Chicago in 1996. The statement was typed and signed, but Dan Pfeiffer claimed that Obama himself hadn't overseen the questionnaire. You can dismiss that as pure positioning (and I have no evidence to rebut you), but it does not seem to me to fit Obama's usual caution on matters that could generate a lot of heat. And in 1996, the number of politicians supporting marriage equality was pitiful (it was the year that DOMA passed). Call me a dupe, but I have come to believe that Obama's position in the 1990s was roughly what it was in 2004 in his Senate race and in 2007, when I heard him talk about it in private. He favored civil unions of some sort but not marriage. We can't read his mind, but the kind of politician who attended an anti-war rally and declare that he was not opposed to all wars is not the kind of politician who would have staked out such a radical stance on gay marriage of all things at the time.
Here's a segment of his 2004 debate with Alan Keyes on the subject. I think it captures Obama's conflicts and doubts and general confusion about the whole thing: