Lena Headey violated her custody agreement with her ex-husband by keeping their son in the U.K., and a judge has just ordered her to come back to L.A. with the kid after the show wraps.
Ex-hubby Peter Loughran was in court Wednesday when the judge made it clear ... the 'GoT' star went crosswise with the 2013 custody agreement by enrolling 6-year-old Wylie in school without Peter's permission.
Peter wanted Wylie returned stat -- the boy was supposed to come back Sept. 5th -- but the judge agreed with Lena that she could keep Wylie in Europe until shooting is over before returning to L.A.
Lena wanted to keep Wylie in England permanently, because she felt the U.S. school system sucked.
The custody agreement gives Peter visitation 10 days a month. Until Wylie comes back home, Lena has to pay for Peter's travel.