Top to bottom: hammer uncocked. Hammer cocked, safety off, ready to fire.
The hammer of a firearm is a part that swings to impart a blow (impact) that will initiate a firing when the trigger is pulled. Its name comes from its resemblance and functional similarity to the common hand tool of the same name. The proximal result of the hammer's blow depends on the mechanism of the lock or action of which it forms a part. For example, in a flintlock, it strikes flint against steel, whereas in a modern lock, it strikes the primer on a cartridge or a firing pin that will strike the primer. The distal result is the same: a firing of the weapon.
When the trigger is pulled, it acts on the sear, which in turn releases the spring-tensioned hammer. Some firearms have a striker instead of a hammer and firing pin.