The Prophet (ﷺ) said: If anyone surrounds a land with a wall, it belongs to him.
Sunan Abi Dawud Book 20, Hadith 150