This is a very unpredictable move on Obama's part, in terms of political repercussions. Very uncharacteristic of his usually methodological and reserved approach.
This could be great, and give him a big advantage because the left will see the election as a referendum on gay marriage and be way more motivated with donations (many will probably consider an Obama loss something that will set the gay-rights movement back a decade). It also has a chance of getting the GOP very off message when they should be focusing on the economy.
On the other hand, this could hypothetically lose Obama a lot of support among swing voters (especially in more working-class states). Not to mention that the religious opposition will be extreme.
If this happens Obama is done for. Romney shall accuse him of trying to shift the election's focus from the economy to try to take off the spotlight from his own failures, whether real or not.