Strategically important , Gibraltar was reluctantly ceded to Great Britain by Spain in the 1713 Treaty of Utrecht ; the British garrison was formally declared a colony in 1830 .