Some things depend on the state in question. Get ready for a hugely personal example:
I have a deeply painful situation right now pertaining to this issue; I relocated to the West Coast from Pennsylvania in March because of an excellent job offer (to my husband) and the unique educational opportunities available (for me). My first marriage ended three years ago; my ex is a fundamentalist Christian who throughout the final 3 years of our marriage was slowly losing his mind over his inability to control me or my beliefs, and it led to an increasingly abusive situation. When he actually began to make threats, I left and took the kids with me.
I never once tried to keep the kids away from him, though I retained primary custody, because overall I believed he was a good father. It seemed I was the catalyst for his insanity. I got a PFA (protection from abuse) based on the threats, and the local police were very watchful, especially if they saw my ex's vehicle near my house.
My impression that I was the trigger for my ex's unstable behavior was reinforced by reports from the kids that he had improved consistently since I left. When our divorce was final, he remarried almost immediately to a woman I believed could be helpful to him and keep him in line. This really seemed to be the case over the past two years, and the kids were happier than ever before (so was I). I retained primary custody, but agreed to joint legal custody.
My children are old enough (17, 15, 10) and mature enough that I believe they should have the freedom to choose where they live, whether that be with me or their father. So when we knew we had to move (there is NOTHING financially feasible in PA in our fields right now), I gave them the choice about where they'd stay when. They chose to stay in PA with their dad for the school year and come to me for vacations.
My ex and I agreed to this before I left, but nothing was done officially. More fool me, expecting integrity where I'd never seen it for myself.
Once I was gone, my ex filed papers behind my back which called my fitness as a parent into question, claiming I never gave him notice when I moved. As a result, my children cannot legally leave the state. I still have primary custody by law, but since I do not live in PA and cannot do so, I can't see my children. Since that time, his lawyer has canceled the court dates repeatedly, so that this is becoming an incredibly long, dragged-out process (sort of like this post - :sorry1:, I never learned the art of brevity).
Lots of other factors have become involved, including the health of the children and his crazy beliefs about medicine. None of this is helping me to expedite the process of even getting heard by a judge. Even when I do get a court date (and I've counter-filed for relocation at the urgent requests of my children and in light of my ex's actions), my lawyer's not optimistic about my chances despite my ex's obvious lunacy.
First, because PA does not like to send the children out of state unless there's family where they're going. Job and school are not enough reason to relocate, in many PA cases.
And second, because I was ok with leaving the kids there in March; all my faith in human nature and hoping he'd changed simply look like indecision to the court. The way many judges see it, this looks like flakiness, which = untrustworthiness; especially in women.
All that to say that even in an extreme case with many factors in the mother's favor, it does not automatically go her way.