Gibraltar’s status is unusual because it is a British Overseas Territory. As such, it has its own Parliament and passes its laws. The UK remains responsible for handling its foreign affairs, including its relationship with Europe and the EU.
Indeed, Gibraltar has an exceptional relationship with the EU. If you come from a Schengen country, you will also be able to visit Gibraltar without a visa. However this only allows for a stay of up to 21 days; if you wish to remain for longer or work in Gibraltar, you will need a visa.
UK nationals will not need a visa to travel to and live in Gibraltar.