
This is the question that gives most people the greatest uncertainty because there are many different descriptions and even HMRC definitions is not entirely clear.
There is a lack of certainty because there is no current tax law defining clearly when someone is or is not UK tax resident. Even if HMRC published law to provide certainty this would get tangled up if another countries tax law decides this same person is also resident or otherwise.
Furthermore UK, EU and other Courts may decide at various levels a different interpretation of your residency and so you rarely get any actual certainty.
So subject to other country or tax treaty arrangement, let's explore the basic rule that the UK will consider you tax resident if you are physically present in the country for 183 days or more in any UK tax year. Tax treaties tend to expand this general rule to 183 days in any 12 months. This tries to prevent people using the span of a tax year to escape residency by day counting alone.
This 183 day rule does not apply in the reverse, ie if you leave the UK and spend less than the 183 days this does not make you non-UK resident!
If your visits to the UK are less than 183 days each tax year but over a 4 year period your visits reach an average of 91 days or more the UK will expect to treat you as UK tax resident.
When you leave the UK, a different less published set of HMRC views apply to you. If you leave the UK and do not step foot in the UK for an entire tax year then you will be treated as not-UK resident for that tax year.
Or, if you leave the UK 'permanently or indefinitely' you will be treated as not UK resident but only if you do not exceed the limits above and only if you can prove you have left the UK 'permanently or indefinitely'. This 'permanently or indefinitely' definition is the tricky part because it prevents you from leaving the UK to enjoy a lifestyle that takes you from country to country as many people do now seeking warmer climates and adventures.
To succeed this 'permanently or indefinitely' test you need to prove a closer connection to your new country of residence that the UK. This can be difficult if you still have family in the UK or property.
A final respite for people leaving the UK for employment is to leave for a complete UK tax year and keep the return visits to the UK as few as possible but certainly less than the 91 day average and HMRC will happily treat you as not UK resident from the date you leave to the date you return.
In countries where a tax treaty exists the test of residency is expanded and if the residency cannot be decided clearly then the two countries will decide through mutual agreement.
The specific opportunities available to you as a resident or non-resident take a careful analysis before deciding the options that best apply to your situation.