Slaves to Armok: God of Blood, Chapter II: Dwarf Fortress

The Manual: Defending the Fortress

You have two main methods of defending yourself: soldiers and traps.

Soldiers

At any time, any dwarf that isn't a noble or a child can be recruited for service. This is done from the military screen, where the dwarves can be organized into squads. Weapon preferences can be set from the soldier preferences menu.
The Military Screen
Setting Soldier Preferences

Dwarves with no weapon skills do not like being drafted, and dwarves with no craft skills do not like being relieved.
Dwarves do not like serving on active duty for long periods of time. Use the squad settings in the military screen to relieve squads for a time. Squads that are standing down will train if you have a barracks or archery targets.

Traps

Traps are another effective method of thwarting your opposition. These come in many forms. The components required depend on the trap, but all traps need mechanisms. You can link levers and pressure plates to certain furniture to trigger more elaborate traps.
The Lever Menu