Halle Berry just emerged from court victorious in her custody battle with Gabriel Aubry ... TMZ has learned ... because a judge just gave her the green light to go across country with her toddler to shoot a movie.
Sources tell TMZ ... Gabriel was trying to block Halle from going to NYC to shoot "New Year's Eve" -- the movie from which she withdrew in order to deal with her custody issues over Nahla.
After hearing arguments this morning from both sides -- as Halle looked on -- the judge gave her the green light to travel to New York with her kid. We've learned she won't take back the role that was given to Katherine Heigl, but she'll play another character in the movie.
Halle's lawyer, Neal Hersh, tells TMZ, "We are pleased the judge took the time to deal with this very imminent and important issue. The judge read a great deal of paperwork and gave us time to argue."
Hersh added, "Halle is very pleased with the judge's order."
We're told Halle is going to NYC soon, but not this week.
As for Gabriel, he has withdrawn his custody petition -- which is public -- but he's continuing his war by filing a paternity action. Paternity cases are not open to the public.
Bottom line ... it's a bitter dispute, but Halle won this battle.