A medieval castle was a wooden or stone building used by rulers to demonstrate their wealth and power and to provide a place of defence in times of war. A medieval castle usually defended a strategically important site like a frontier, river crossing, or valley pass. Many castles had a permanent garrison of soldiers.