In 1869 King William I of Prussia (later also German Emperor) founded the town as an exclave of the Province of Hanover and a naval base for Prussia's developing fleet. All the hinterland of the city remained as part of the Duchy of Oldenburg.
Text: Wikipedia
More information about racism and colonialism in the German Kaiserreich here (German):
https://m.dw.com/de/rassistisch-r%C3%BCcksichtslos-grausam-die-deutsche-kolonialgeschichte/g-35991790