When you get an infection, your immune system is on the case with a team of cells that specialize in tackling disease. The vastness and complexity of this team may surprise you.
Microbes that attack the body are covered with molecules called antigens. Microbes are overtaken by macrophages (Greek for "big eaters").
Macrophages digest most of a microbe but deliver the antigens to immune system cells like lymphocytes (white blood cells) in the lymph nodes.
T cells and B cells are the two main types of lymphocytes. T cells and helper T cells activate killer T cells. Helper T cells nudge and work with B cells.
B cells make antibodies which attach to the microbe and coat it. Antibodies and antigens that fit together will bind together. Each B cell produces a particular antibody which will bind with a particular antigen.
Upon contact with their particular antigen, each B cell divides into plasma cells which overwhelm the microbe with antibodies. These antibodies roam the body, attacking microbes before they've had a chance to infect, and disabling them.
The immune response also produces memory cells that loiter in your bloodstream, on the lookout for that same type of disease-causing agent. Memory cells act quickly, causing the disease-causing agent to become inactive and keeping you from getting sick. A really fast response will prevent any infection, bestowing immunity from that particular illness.
Some B cells and T cells become memory cells after the infection is eradicated. Memory B cells divide into plasma cells that will make more antibody. Memory T cells divide and grow to protect against microbes. Re-exposure will cause the immune system to recognize that particular type of microbe, and mobilize again.
This is how your body acquires active immunity naturally. It can also be provided by vaccines. Another kind of immunity called passive immunity occurs when antibodies are transmitted from one body to another.
This can happen through the mother's placenta or breast milk, or through transference of lymphocytes. It can also happen through vaccination.