Like many gay Americans, I was thrilled when President Obama endorsed same-sex marriage. But maybe not for the reasons you think.

We need gay marriage so we can have gay divorce.

As a lesbian who came out in the 1970s, I never thought I’d see such progress in my lifetime — or that I’d become an avid proponent of a legal convention I once thought too traditional and too imitative of heterosexuality.

But I learned the hard way why matrimony affords necessary protection and how anything less is separate and unequal. Obama said as much when he shifted his support from civil unions to marriage in an “evolution” on the issue that seems to have come to its happy end last month.

Last June, on the night Albany ushered in same-sex marriage across New York State, I stood cheering in front of the Stonewall Inn (the epicenter of the gay rights movement) on Christopher St. Couples were hugging, kissing, crying. I even overheard a proposal.

But the victory was bittersweet for me. I was single, after my partner of 26 years had dumped me and walked away without looking back.

My ex and I were domestic partners who had registered at the Municipal Building in 1993. The partnership offered very few legal benefits, but it was as significant to us as a marriage license. It represented our commitment.

I returned to the same lower Manhattan office in 2008, now on my own, to dissolve our partnership. Terminating cost a mere $32.50 and did not require my former partner’s presence — or even her signature. I was well aware this procedure was a joke. But I wanted an act of closure.

My former partner didn’t meet anyone new; she just wanted to be free to see what she missed — a midlife crisis right after she turned 50.

I once saw myself as the nontraditional Greenwich Village dyke who rebelled from my conservative Catholic family in New Jersey, only to realize I had become, in time, the loyal lesbian wife whose spouse got bored and took off. My efforts to save the relationship failed miserably, and my ex cut off communication because she had to go “cold turkey.” She refused to go to counseling.

We had been a hip downtown artist couple who somehow managed to slip into the cliche of a middle American heterosexual marriage — but without the benefits that automatically come with tying the knot. As I pondered my predicament, I became the queer version of a desperate housewife.

And I was devastated by how badly my (not legal) marriage ended. My therapist diagnosed me with posttraumatic stress disorder.

After devoting 26 years to our relationship, all I had was two boxes of photographs and bundles of cards and letters saying how much she loved me.

When I consulted a lawyer, I learned I had no rights to any financial compensation. Never mind that my ex made more than me and I had helped her launch her successful photography career — the lack of a marriage license entitled me to no compensation.

The attorney suggested I write her a letter stating my case for a “good-faith” settlement, pointing out sacrifices I’d made over the years as the supportive partner to a successful woman.

I sent the letter — and she replied by telling me to leave her alone.

Though far from amicable, it turns out her refusal was perfectly legal, as we had never been more than partners.

And since my ex was the one with money saved for our retirement, I worried I’d land up a bag lady or have to spend my later years living with a sibling in New Jersey. If we’d been married, my lawyer could have argued for equitable distribution of her accounts. My name was listed as a beneficiary but, not being wed, I had no legal claim unless she died.

I spent a lot of time talking to my therapist, writing in my journal and praying.

Eventually, my mother and I got closer; my friendships deepened and I joined a vibrant church. I landed a full-time job as a college teacher. I moved into a fabulous new apartment.

In short, I bounced back. I’m much better off single than getting old with the wrong person.

My recovery took longer than expected — and it would have been easier with a divorce settlement. But I know my new partner is out there. Next time, I hope to have a legal marriage.