You are absolutely correct that a quark and an antiquark are fundamental particles, yet they can interact and form new ones. When they meet, they intermingle and form a “virtual photon” — a photon that lives for only a very short time. A photon is another name for a particle of light, like those that make up what you see from a light bulb or those that compose higher-energy X-rays.
Astronomy magazine subscribers can read the full answer for free. Just make sure you're registered with the website.