Summary:
A city's owner may "garrison" a military unit inside the city to bolster its defenses. A portion of the garrisoned unit's combat strength is added to the city's strength. The garrisoned unit will take no damage when the city is attacked; however, if the city is captured the garrisoned unit is destroyed.
A unit stationed in the city may attack surrounding enemy units, but if it does so the city loses its garrison bonus, and, if it's a melee attack, the unit may take damage during the combat as normal.