Tetanus, also sometimes called "lockjaw", is caused by a toxin produced by a bacteria called Clostridium tetani. C. tetani is found all over, including soil (the garden and field kind), stool and manure, and anything lying on the ground. Rusty metal is also a favourite place for C. tetani to hang out, and in fact puncture wounds with rusty nails are a common cause of tetanus. C. tetani grows in wounds, especially closed wounds like punctures, and produces a toxin that paralyzes muscles -- thus the term "lockjaw". In the worst case tetanus can kill by paralyzing the breathing muscles. Although C. tetani itself can be treated easily with penicillin, antibiotics will not destroy or neutralize the toxin. Antibodies to the toxin can bind to and inactivate the toxin before it attacks muscles and nerves.
There are actually two agents we can use to protect against tetanus. One is "antitoxin" or tetanus immune globulin (TIG), which is a concentrate of antibodies produced against tetanus toxin by immunized people. (TIG, like other immune globulins, is produced by a process which kills any virus in the donor's blood. Specifically, the process will kill HIV.) TIG can be used if someone with no immunity to tetanus develops an infection, or is risk of an infection.
The other agent is tetanus toxoid, prepared by taking toxin and treating it chemically so that it cannot cause paralysis. Although it will not harm you, the inactivated toxin will make your body produce antibodies to the toxin and thus protect you against future infections -- for a while. Immunity to tetanus wears off eventually, and so you need boosters at regular intervals throughout life.
The best protection from tetanus comes from toxoid-induced immunity. The initial immunizations are a series of three shots given at ages 2, 4, and 6 months of age. This is followed by boosters at 12-18 months and at 5 years. After this "primary series" you need to have a booster every ten years for your entire life. The tetanus toxoid is almost always given to small children as part of the DPaT vaccine, which also contains vaccines for diphtheria and pertussis (whooping cough); there are now vaccines that contain the three vaccine in DTaP and the vaccines for Haemophilus influenzae type b (HiB) and for hepatitis B, which cuts out a lot of the needle pokes while still immunizing children against all of these diseases. For older children, we now have Tdap, which combines tetanus toxoid with the vaccines for diphtheria and meningococcus; some adults may also need this vaccine. (By the way: the tetanus toxoid given to adults is almost always combined with the toxoid used to vaccinate against diphtheria.)
If you are exposed to tetanus within 5 years after your last dose of vaccine (toxoid), you do not need a booster. If it's between 5 and 10 years after your last dose, you need an early dose of vaccine. If you haven't had a tetanus immunization in more than 10 years you will need to have both toxoid and TIG to give you full protection.