5th & 14th
While the 5th is most known for the right to remain silent, it also has a due process clause in it
the 14th also has the same due process clause, but it extends to states, while the 5th had been just applied to the federal government
I would have guessed the court would apply the 14th amendment equal protection clause as the reason for gay marriage, as it bans discrimination. the SCOTUS ruling cited both the 14th Amendment's equal protection and due process clauses. Since the right to marry is considered a fundamental right, or liberty, then you can't deprive someone of the right to marry without due process.
Even Charles Manson was allowed the right to marry while in prison. He called it off when he thought his "fiance" was just in it for money to do a book deal or something similar. yet, even a mass serial murderer had the fundamental right to marry. If so, why not gays?