Gary Grantham was the gay fiance of Susan Mayer in season two when she needed health insurance and he needed to woman to pass on as his wife so his mother would die happily.
During some point in his life, Gary realized he was gay but he knew his mother always wanted him to get married to a woman and start a family. Gary kept being gay in the closet to his mother even though he had a gay fiancee. Gary decides to find a woman to marry so his mother will die happily. That's where Susan Mayer comes in. ("Silly People")
Gary meets Susan Mayer through Edie Britt who is trying to help Susan find a husband with good health insurance. Susan and Gary are at City Hall and almost get married when Gary's life partner Steven convinces Gary not to care how his mother feels and Gary leaves Susan at the alter. ("Silly People")