Context : Aims : We report the detection of hard X-ray emission from the field of the star-forming region NGC 6334with the the International Gamma-Ray Astrophysics Laboratory INTEGRAL . Methods : The JEM-X monitor and ISGRI imager aboard INTEGRAL and Chandra ACIS imager were used to construct 3-80 keV images and spectra of NGC 6334 . Results : The 3-10 keV and 10-35 keV images made with JEM-X show a complex structure of extended emission from NGC 6334 . The ISGRI source detected in the energy ranges 20-40 keV , 40-80 keV , and 20-60 keV coincides with the NGC 6334ridge . The 20-60 keV flux from the source is ( 1.8 \pm 0.37 ) \times 10 ^ { -11 } ~ { } erg~ { } cm ^ { -2 } ~ { } s ^ { -1 } . Spectral analysis of the source revealed a hard power-law component with a photon index about 1 . The observed X-ray fluxes are in agreement with extrapolations of X-ray imaging observations of NGC 6334by Chandra ACIS and ASCA GIS . Conclusions : The X-ray data are consistent with two very different physical models . A probable scenario is emission from a heavily absorbed , compact and hard Chandra source that is associated with the AGN candidate radio source NGC 6334B . Another possible model is the extended Chandra source of nonthermal emission from NGC 6334 that can also account for the hard X-ray emission observed by INTEGRAL . The origin of the emission in this scenario is due to electron acceleration in energetic outflows from massive early type stars . The possibility of emission from a young supernova remnant , as suggested by earlier infrared observations of NGC 6334 , is constrained by the non-detection of ^ { 44 } Ti lines .