If you come to the UK from abroad and want to claim certain benefits, you must pass a test, known as the habitual residence test which is carried out to make sure that if you're planning to claim benefits, you've a legal right to be in the UK and that you're intending to settle here for the time being.
The test also applies to British citizens returning to the UK after time abroad, as well as people coming to the UK from other countries.
The right to claim benefits depends on what terms you've been allowed to enter the UK. This is called your immigration status. If you're subject to immigration control, you can't claim benefits and making a claim may affect your right to stay in the UK.
Full details of the Habitual Residence Test and claiming benefits can be found at:
Information on what to do if you have failed the Habitual Residence Test are available at this link.
Claiming benefits if you're from the EU
Full details of claiming benefits if you're from the EU can be found at this link.