In 1665 Robert Hooke put a nettle hair under his microscope and drew what he saw: a bristle-like tube with a small bag at the base. He called the tube a syringe-pipe and guessed that the bag held a corrosive liquid that escaped when the tip broke. He had no way to test the guess, and he was essentially right. Three and a half centuries later, the description still holds, with a better vocabulary and a longer list of chemicals.

A single cell that does two jobs
A stinging hair on a nettle is one elongated epidermal cell, not a multicellular spine. Its base is swollen and sits in a socket of ordinary epidermal cells. The shaft narrows as it rises, and the tip is thickened with silica, which is to say glass. Where the silica cap meets the softer wall there is a line of weakness, pre-formed, waiting.
Brush against it and the cap snaps off at that line, leaving an angled, hollow needle with a stiffened wall. The pressure of the same movement squeezes the bulbous base, and the cell empties its contents into the skin. The whole apparatus is a disposable hypodermic: it works once, and then it is a blunt tube.
The elegance is in the economy. There is no muscle, no trigger, no nervous system. The geometry does all the work, and the animal supplies the force by walking into it.
What is actually in the syringe
The payload is a mixture, and the mixture is why the sting feels the way it does.
Histamine is there, the same molecule your own mast cells release in an allergic reaction. It dilates small blood vessels and makes their walls leaky, which produces the redness and the raised weal. Acetylcholine is there too, a neurotransmitter that excites pain fibres directly, so the sharpness arrives before any inflammation has had time to build. Serotonin, another signalling molecule, adds to the burning and the itch. Organic acids, oxalic and tartaric among them, are thought to prolong the sensation after the amines have been cleared.
The substance most people name is the one that matters least. Formic acid, the acid of ant stings, is present only in small amounts, and the older textbook claim that it is the main irritant does not survive a modern analysis. The genus name Urtica comes from the Latin for burning, not from formic acid, and the chemistry behind the burn is a cocktail rather than a single ingredient.
Why this is not an allergy
A nettle rash looks like hives and is often described as one, but the mechanism is different in an important way. In an allergy, your immune system has to be sensitised before it reacts, and reactions can escalate with repeated exposure. Here the plant arrives with the histamine already made. Nearly everyone reacts on first contact, and repeated stings do not make the response worse in the way that poison ivy does.
That distinction is worth making explicit in a classroom, because "histamine" tends to be filed under allergy and the nettle is a clean counterexample. The molecule is the same; the route is entirely different.