The Trifid Nebula , a young star-forming HII region , was observed for 16 hours by the ACIS-I detector on board of the Chandra X-ray Observatory . We detected 304 X-ray sources , thirty percent of which are hard sources and seventy percent of of which have near-infrared counterparts . Chandra resolved the HD164492 multiple system into a number of discrete X-ray sources . X-ray emission is detected from components HD164492A ( an O7.5III star which ionizes the nebula ) , B and C ( a B6V star ) , and possibly D ( a Be star ) . Component C is blended with an unidentified source to the NW . HD164492A has a soft spectrum ( kT \approx 0.5 keV ) while the component C blend shows much harder emission ( kT \approx 6 keV ) . This blend and other hard sources are responsible for the hard emission and Fe K line seen by ASCA , which was previously attributed entirely to HD 164492A . The soft spectrum of the O star is similar to emission seen from other single O stars and is probably produced by shocks within its massive stellar wind . Lack of hard emission suggests that neither a magnetically confined wind shock nor colliding wind emission is important in HD164492A . A dozen stars are found to have flares in the field and most of them are pre-main sequence stars ( PMS ) . Six sources with flares have both optical and 2MASS counterparts . These counterparts are not embedded and thus it is likely that these sources are in a later stage of PMS evolution , possibly Class II or III . Two flare sources did not have any near-IR , optical , or radio counterparts . We suggest these X-ray flare stars are in an early pre-main sequence stage ( Class I or earlier ) . We also detected X-ray sources apparently associated with two massive star forming cores , TC1 and TC4 . The spectra of these sources show high extinction and X-ray luminosities of 2 - 5 \times 10 ^ { 31 } erg s ^ { -1 } . If these sources are Class 0 objects , it is unclear if their X-ray emission is due to solar-type magnetic activities as in Class I objects , or some other mechanism .