Allergic reactions are caused by the sudden release of chemicals, including histamine, from cells in the body. The release is triggered by the reaction between the immune system antibodies (called Immunoglobulin E or IgE) and the food or substance (known as an allergen) it has been exposed to.
The body will have been exposed to the allergen on a previous occasion, although the person may not have been aware of this at the time. On that earlier occasion, the allergen was wrongly identified as a threat and antibodies were made against it, which means that on the next exposure, a serious reaction may occur.
The mechanism is so sensitive that sometimes even tiny amounts of the allergen can cause an allergic reaction.