When an immune system is exposed to molecules that are foreign to the body (non-self), it will orchestrate an immune response, but it can also develop the ability to quickly respond to a subsequent encounter (through immunological memory). This is a function of the adaptive immune system. Therefore, by exposing an animal to an immunogen in a controlled way, their body can learn to protect itself: this is called active immunisation.
The most important elements of the immune system that are improved by immunisation are the B cells (and the antibodies they produce) and T cells. Memory B cell and memory T cells are responsible for a swift response to a second encounter with a foreign molecule. Passive immunization is when these elements are introduced directly into the body, instead of when the body itself has to make these elements.
Immunisation can be done through various techniques, most commonly vaccination. Vaccines against microorganisms that cause diseases can prepare the body's immune system, thus helping to fight or prevent an infection. The fact that mutations can cause cancer cells to produce proteins or other molecules that are unknown to the body forms the theoretical basis for therapeutic cancer vaccines. Other molecules can be used for immunisation as well, for example in experimental vaccines against nicotine (NicVAX) or the hormone ghrelin (in experiments to create an obesity vaccine).
Active immunization can occur naturally when a person comes in contact with, for example, a microbe. If the person has not yet come into contact with the microbe and has no pre-made antibodies for defense (like in passive immunization), the person can become immunized. The immune system will eventually create antibodies and other defenses against the microbe. The next time, the immune response against this microbe can be very efficient; this is the case in many of the childhood infections that a person only contracts once, but then is immune.
Artificial active immunization is where the microbe, or parts of it, are injected into the person before they are able to take it in naturally. If whole microbes are used, they are pre-treated, so that they will not harm the injected person as the naturally occurring microbe would. Depending on the type of disease, this technique also works with dead microbes, parts of the microbe, or treated toxins from the microbe.
Artificial passive immunization is normally given by injection and is used if there has been a recent outbreak of a particular disease or as an emergency treatment to poisons (for example, for tetanus). The antibodies can be produced in animals or in vitro.