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.
TMZ broke the story ... Peter got pissed when Lena moved with their kid to the U.K. after she claimed he agreed they'd both live there and share custody.