An airlock or fermentation lock is a single direction sanitary valve used during fermentation. It allows the large quantities of carbon dioxide being produced by the yeast to escape while not permitting outside air\oxygen or contaminants to enter the fermentation chamber. This creates a sanitary seal on the fermenter and helps prevent the oxidization of the fermenting beer.
The airlock or fermentation lock typically contains a sanitizer to help maintain the integrity of the fermenter. Airlocks tend to be made of clear plastic or glass so that the CO2 bubbles passing through them can be monitored as a way of gauging how active the fermentation process is.
Below is an example of a three piece airlock, S shaped airlock, and a blowoff tube.