The first attempt to detect X-rays from the moon in 1962 failed. (The attempt was not a complete failure, though, because during the telescope's flight, the first extrasolar source, Scorpius X-1 was detected. Scorpius X-1 is a binary star system, see Binaries section for more.) As it turns out, the moon is a source of both X-rays and gamma-rays; however they arise from different processes.
For reference, here is the Moon as you and I see it:
Image of the Moon in visible light from Consolidated Lunar Atlas.
If we could see in X-rays, the Moon would look a bit like this:
Image of the Moon taken by ROSAT, an X-ray satellite, on June 29, 1990.
The image was taken when the Moon was about half-full. Since most of the X-rays are coming from the same part of the moon illuminated by the sun, the source of the Moon's X-rays must be related to the Sun. In fact, this is the case. The Moon reflects X-rays from the Sun, just as it reflects visible light.
You may have noticed that there were a few dots of X-rays in the Moon's dark half. Here, the moon is not reflecting the Sun's X-rays, since it is not in the direct light of the Sun. Instead, charged particles (like protons and electrons) in the Sun's solar wind can reach the far side of the Moon, and they produce X-rays in much the same way that cosmic rays produce gamma-rays on the Moon. Read the next section of the gamma-ray Moon to learn about that.
You might also have noticed the polka-dotted appearance of the image. The sources that are outside of the circle defined by the Moon are from an X-ray background. ROSAT was not able to resolve many of the X-ray sources in the sky, so it observed them as a diffuse background. This is like when you sit in a big auditorium; rather than hearing each individual conversation of people in the auditorium, you hear a jumbled buzz of sound from all directions.
Here is an image of the Moon taken in gamma-rays:
Image of the Moon taken by the EGRET instrument aboard the CGRO satellite. This is a composite of 8 exposures taken during 1991 - 1994.
The gamma rays from the Moon do not come from reflected gamma rays of the Sun. Instead, high energy particles (mostly protons) that are travelling very close to the speed of light, called cosmic-rays, continuously slam into the Moon. When these particles collide with the lunar surface, they react with the particles in the Moon's surface, exciting them and generating gamma rays. This process is similar to what goes on in particle accelerators on Earth.
The Moon is brigher in gamma rays than the quiet Sun! In fact, the most sensitive gamma-ray detector flown to date, EGRET aboard the CGRO satellite, was not able to detect the quiet Sun. (The Sun goes into periods of extreme activity, during which it is called an active Sun; the Sun is said to be quiet when it is not experiencing such activity.)
The mottled portion of the above image is actually an gamma-ray background. Just like in the image of the X-ray Moon, the instrument which took this image was not able to resolve all of the gamma-ray sources in its field of view. These unresolved sources appear as a diffuse background.