Having been both an ex-pat and an immigrant, the transition occurs when you decide to stay permanently.
My father emigrated from New Zealand to the UK with no plans to return in the foreseeable future (it was 1952; you couldn't hop on a 747 and go home for xmas for a week or two's wages!)).
In 1968 we came to Australia for a three year contract, extended to five in 1971, making us expatriates until in 1973 when my parents decided to stay here, transitioning from ex-pats from the UK to immigrants.