Pretty surprised that it is Obito, unless there is a decent explanation, there are far too many plot holes. I can see only three viable explanations for this.
1) Normally the Mangekyo is unlocked from the trauma of the loss of the person closest to you. However, given the nature of the trauma Obito was dealing with, what if, on the verge of death he unlocked his t/s abilities and sucked himself in to the other dimension. Perhaps time moves faster in this dimension; he meets Madara, trains, taught Madara's values, etc.
2) Madara finds Obito's broken body, uses Zetsu to help repair him, makes him his disciple, trains him... and the rest is history.
3) Orochimaru left the village at approximately the same time that Obito died. As we know, Danzo was quite the planner. Maybe the two of them more or less created Zetsu, and Franken-Obito for the sole purpose of eliminating the Uchiha as Madara. Without purpose, he leaves the village, meets Madara somehow... etc. There is plenty of connection between Danzo and Ororchimaru, and Kabuto knew who Tobi was immediately.... with the whole, oh you go by Madara now comment.
I don't know, just spit-balling here. I think some combination of option two and three are probably most likely, but either way Kishi has a lot of 'splaining to do.