The spores of the fungus attach themselves to the external surface of the ant, where they germinate. They then enter the ant's body through the tracheae (the tubes through which insects breathe), via holes in the exoskeleton called spiracles. Fine fungal filaments called mycelia then start to grow inside the ant's body cavity, absorbing the host's soft tissues but avoiding its vital organs.
When the fungus is ready to sporulate, the mycelia grow into the ant's brain. The fungus then produces chemicals which act on the host's brain and alter its perception of pheromones. This causes the ant to climb a plant and, upon reaching the top, to clamp its mandibles around a leaf or leaf stem, thus securing it firmly to what will be its final resting place.
The fungus then devours the ant's brain, killing the host. The fruiting bodies of the fungus sprout from the ant's head, through gaps in the joints of the exoskeleton. Once mature, the fruiting bodies burst, releasing clusters of capsules into the air. These in turn explode on their descent, spreading airborne spores over the surrounding area. These spores then infect other ants, completing the life cycle of the fungus.
I think I found this post especially vivid because I just finished reading the Worlds trilogy (Joe Haldeman), in which humans colonizing a new planet are terrorized by the Eveloi, a parasitic species that directs its hosts' actions by means of a tiny filament accessing the brain through a hole in the skull. (An interesting thing I noticed about the Worlds books -- there are references throughout, in character and place names, to giants of sci-fi/futurism like Asimov, Heinlein, and some others that seemed familiar but I couldn't place.)