X-ray tubes work by firing electrons at a metal plate in a vacuum. When an electron passes near the nucleus of one of the atoms in the plate, it is accelerated and emits x-rays, as shown in the drawing on this Hyperphysics page. To learn more, visit Hyperphysics: X-ray tube.