Phenergan works by blocking the action of histamine, a natural substance produced by the body during an allergic reaction. This helps to relieve the symptoms of hayfever and other allergies such as itching, runny nose, and sneezing.