X-Rays are produce when electrons strikes metal target. The electrons are liberated from the heated filament and accelerated by high voltage towards the metal target. The X-Rays are produced when the electrons collide with the atoms and nuclei of the metal target.
November 8, 1895 Roentgen noticed that when he shielded the tube with heavy black cardboard, the green fluorescent light caused a platinobarium screen nine feet at away to glow too far reacting to the cathode rays as he understood them. He determined the fluorescence was caused by invisible rays originating from the Crookes tube he was using to study cathode rays which was late recognized as electrons.
X-Rays were found to able to penetrate through materials of light atoms like flesh. The heavier atoms like metal absorb them. A beam of high energy electrons crashes into a metal target and x-ray are produced. A filter near the x-ray source blocks the low energy rays so only the high energy rays pass through a patient toward a sheet of film. Along with the sheet film, a second sheet film is placed on the body, this allows the technician to take the picture and an x-ray is developed to solve or analyze the problem.
In the early days of X-ray's science, a lot of doctors would expose patients and themselves to the beams for long periods of time. Eventually doctors and patients started developing radiation sickness, and the medical community knew something was wrong.