In the anime, Ash used a Haunter to battle Sabrina. I don't remember much after. Then Haunter is not seen afterward. What happened to him?
Ash used a Haunter to battle Sabrina
not exactly, Ash befriended Haunter (as he was never really caught with a Pokeball) to fight against Sabrina's Kadabra but it never actually was used in battle. the first time it had wandered off and in their escape Brock and Misty were caught and turned into dolls
Ash returned with a Haunter he had befriended. Ash challenged Sabrina to a rematch, but Haunter had wandered off in the meantime. Ash managed to escape Sabrina's wrath, rescued by the mysterious man once again, but Brock and Misty were transformed into dolls and placed into a dollhouse, where they met Sabrina's mother in the same predicament.
and Haunter still didn't fight in the second re-match
Ash returned once more, and during the match, Haunter appeared and started to playfully tease Sabrina. Haunter's antics delighted Sabrina so much, that she was no longer able to contain her emotions and started to laugh. This caused her two personalities to merge back into one. Ash was deemed the winner of the match due to the inability of Sabrina or her psychically-linked Pokémon to battle, and he won the Marsh Badge. Haunter chose to stay with Sabrina and her reunited family.
as you can see after Sabrina's personalities merged back together and everyone was restored Haunter decided to remain with Sabrina and her family.