Militia are troops that belong to a region rather than to a particular troop leader. They are paid out of the region's tax gold before the region commander gets a share. When they are set up, they lose all their previous settings and designations (front/back, sentry/army, etc), and set themselves up specifically as militia.
Militia dig in whenever they get the opportunity, and will automatically re-assemble if they've been scattered or forced to retreat in battle.
Existing militia units can be reinforced by the local lord, but are otherwise not automatically replaced. This means that even without combat, their numbers will drop slowly, and over time they will disappear. For larger units, this is a very slow progress, and a militia unit placed in a region will still be around months, sometimes years later. Smaller units, however, sometimes disintegrate in a matter of weeks.
A troop leader can place his unit as militia by travelling to that region and then selecting "Abandon your unit..." and then "Set up the unit as a local militia." You must have been playing Battlemaster for at least 9 days and have at least 2 prestige to set up your unit as militia. If you have more than 50 men, more healthy men than wounded men, and more than 2 prestige you can disband half your unit. If you have more than 50 men, more healthy men than wounded men, and more than 10 prestige, you can choose how many men to disband.
If the unit is big enough, a troop leader can choose to set down only half of his troop as militia. In this case, the other half is retained by the troop leader, which keeps the captain and the unit's stats for the half retained by the troop leader.
Militia can be assigned to unitless troop leaders by the General of the realm, though this can be a buggy process.