The solid-bodied instrument was developed in the 1950s by Leo Fender and Les Paul. Electromagnetic pickups set under the strings detect vibration (Source).
But how does it work exactly? How does the sound travel from the guitar to the pickups to the amplifier? And how come not all guitars sound the same? This page breaks it down with a guide and a video for a quick crash course about the electric guitar pick-ups.