Thanks Jenna and Kate.
I had read about the US laws already on this site, especially that what matters is what is true at the time of the contract.
It would be interesting to hear about Australia and some other countries which are generally liberal regarding trans issues, but do not recognize same-sex marriages. Does the same principle as in the US apply in these countries, or are there other interpretations too?
Actually in India (where I live), the situation is a little more complicated. On one hand, same-sex relationships have no legal recognition, but on the other, there are sometimes reports even in mainstream media of same-sex couples getting married, not just in the big cities but even in remote rural areas. This is possible because legal recognition matters only for 'registering' a marriage, not for getting a priest to officiate it at home or in a temple. In one case, a court even ordered police protection for a lesbian couple being threatened by their families. And there are also reports of same-sex couples raising children of one of the partners from a previous marriage. So I think it is all a bit fluid and varies by the specifics of each case.
But I did not find any case similar to mine here, so I was not sure. Although the bigger problem, as Jenna mentioned, might be dealing with 'confused bureaucrats' on a regular basis rather than a one-time legal battle. And even more so, dealing with social opposition which may have a greater and more frequent impact.