A laser will lase as long as you pump the amplifying medium (continuous, or CW lasers). In this operating mode, stimulated emission depletes the lasing medium from its stored energy as soon as created (through pumping). There is nothing wrong with that for a CW laser, but what if what you are interested in is a short and intense pulse ? The pulse will never be shorter than pumping itself.
How can on make a pulse shorter than the pumping ?
The answer to that is : "Prevent the laser from lasing during pumping !". That way, laser emission will not deplete the lasing medium from its stored energy. In fact, if a laser cavity is blocked (by a shutter) during pumping, considerably more energy can be stored in the medium than is possible if the laser is allowed to lase. When pumping is completed, then allow the laser to lase (open the shutter). The large amount of energy stored in the medium will translate into a high gain in the medium, a gain much higher than that observed in a CW laser. In turn, high gain causes the intensity inside the cavity to grow very rapidly : all the stored energy escapes now as a big, short pulse, instead of a CW emission.
What we have just described is called "Q-Switching". The letter "Q" refers to the quality of the cavity. When the shutter is closed, the cavity has low Q. After the shutter is opened, the cavity becomes a genuine, high Q cavity.
So the key to Q-Switching is a shutter. It has to be very fast, else the lasing medium will spontaneously lose its energy before lasing takes place. Fast shutters are usually obtained by the combination of a Pockels cell and a polarizer inside the laser resonator. Note that because light makes a round trip through the Pockels cell, voltage is adjusted so that the polarization will make a quarter of a turn after going twice through the Pockels cell.
Somewhat slower shutters can be made with acousto-optic modulators.