Herbig-Haro (HH) objects have been known for 50 years to be luminous condensations of gas in star-forming regions, but their underlying physical nature is still being elucidated. Previously suggested models encompass newborn stars, stellar winds clashing with nebular material, dense pockets of interstellar gas excited by shocks from outflows, and interstellar `bullets' (ref. 6). Recent progress has been made with the jet-induced shock model, in which material streams out of young stellar objects and collides with the surrounding interstellar medium. A clear prediction of this model is that the most energetic Herbig-Haro objects will emit X-rays, although they have not hitherto been detected. Here we report the discovery of X-ray emission from one of the brightest and closest Herbig-Haro objects, HH2, at a level consistent with the model predictions. We conclude that this Herbig-Haro object contains shock-heated material located at or near its leading edge with a temperature of about 106K.