Gates are one of the fortifications in Age of Empires II. It acts as a entrance, automatically opening to let friendly units through but preventing enemy units from coming through. This makes city walls much stronger, as it allows for units to move in and out of walled areas without leaving gaps. Gates can be built on existing walls. Gates have more hitpoints than walls, but their greater surface area makes them far more vulnerable as more units can attack them at once.
Note that, unlike in later games, enemy soldiers can pass through the gate if it opens for a friendly uniy. Locking a gate while prevent this but will keep it shut at all times.
Gates were built into walls to allow access to a fortification. Because gates could be the most vulnerable part of a defensive position, extra care was taken to make them strong. A common type of gate was the portcullis, a heavy metal grid that was raised by a winch. The portcullis was in place by grooves in the stonework of the gateway and by its own weight. A long narrow passage, open from above, was usually placed behind the portcullis. Attackers who managed to get past the gate would then remain vulnerable to fire from soldiers in the narrrow passage.