Their relationship was not very good in general. It is unknown when they started dating but it's known that they separated in the "Pilot" and they officially were divorced in "Twenty-Five Little Pre-Pubers Without A Snoot-ful".
In Big Flappy Bastards, Alan goes to Judith’s place to help her with house chores. His original intentions are that he loves her and wants her back. When Charlie suggests to Alan that he is being used, Alan snaps at Charlie, denies his assumptions and leaves. Afterwards, when fixing a leaky sprinkler, Alan tells Judith that he's had enough trying to win her back and that she is free, the two end up sharing a kiss, making him stay with her. Later on, Alan realizes that his marriage is over when Judith explains that she kissed him only because she was afraid of him leaving her. The seagulls also leave Jake’s room when they start feeling hungry.
Judith said that they could not continue their relationship because she had become a lesbian, but in "Alan Harper, Frontier Chiropractor" it was confirmed that that was only an excuse to divorce Alan. Judith finally reveals in "A Pot Smoking Monkey" that she always detested Alan, even before they committed (after he went to Judith's house and asked if he could ask for a divorce lawyer for Alan and Kandi. But she said no because she represented her and then Alan asked Judith when she began to hate him so much).
Despite all this, Judith and him also had good times. For example, in the episode "Go Get Mommy's Bra", when she broke up with her boyfriend Greg and Alan went to genuinely comfort her, she accepted his kindness and rested on his shoulder as he hugged her. They soon made out and were about to have sex until Charlie and Jake arrived at home, interrupting the encounter. It was likely this brought up old feelings, as in "Carpet Burns and a Bite Mark", they began to date again and had sex, something they both enjoy but after getting into yet another argument with her, Alan decides not to see her anymore.
When she and Herb have marital problems in "It's Always Nazi Week", Alan is pleased at her second failed marriage and went to see her house to gloat. After she broke down, he comforted her while he secretly took pleasure in her sadness but said she was still attractive for her age, as she was surprised at this. Judith then kissed him intently, which surprised him though he returned it before they have an affair by having sex.
In "Cab Fare and a Bottle of Penicillin", Alan goes to talk with Judith. She and Alan briefly reunite over their lives and share a kiss but its awkward, they try to leave it but kiss again and drunkenly have sex while getting engaged. The relationship comes to an end when Judith finds out that Alan proposed to Lyndsey before her.