Context : Sagittarius B2 is one of the most massive and luminous star-forming regions in the Galaxy and shows a very rich chemistry and physical conditions similar to those in much more distant extragalactic starbursts . Aims : We present large-scale far-infrared/submillimeter photometric images and broadband spectroscopic maps taken with the PACS and SPIRE instruments onboard Herschel . Methods : High angular resolution dust images ( complemented with Spitzer MIPS 24 \mu m images ) as well as atomic and molecular spectral maps were made and analyzed in order to constrain the dust properties , the gas physical conditions , and the chemical content of this unique region . Results : The spectra towards the Sagittarius B2 star-forming cores , B2 ( M ) and B2 ( N ) , are characterized by strong CO line emission ( from J =4 to 16 ) , emission lines from high-density tracers ( HCN , HCO ^ { + } , and H _ { 2 } S ) , [ N ii ] 205 \mu m emission from ionized gas , and a large number of absorption lines from light hydride molecules ( OH ^ { + } , H _ { 2 } O ^ { + } , H _ { 2 } O , CH ^ { + } , CH , SH ^ { + } , HF , NH , NH _ { 2 } , and NH _ { 3 } ) . The rotational population diagrams of CO suggest the presence of two different gas temperature components : an extended warm component with T _ { rot } \sim 50-100 K , which is associated with the extended envelope , and a hotter component at T _ { rot } \sim 200 K and T _ { rot } \sim 300 K , which is only seen towards the B2 ( M ) and B2 ( N ) cores , respectively . As observed in other Galactic Center clouds , such gas temperatures are significantly higher than the dust temperatures inferred from photometric images ( T _ { d } \simeq 20 - 30 K ) . We determined far-IR luminosities ( L _ { FIR } { ( M ) } \sim 5 \times 10 ^ { 6 } L _ { \odot } and L _ { FIR } { ( N ) } \sim 1.1 \times 10 ^ { 6 } L _ { \odot } ) and total dust masses ( M _ { d } { ( M ) } \sim 2300 M _ { \odot } and M _ { d } { ( N ) } \sim 2500 M _ { \odot } ) in the cores . Non-local thermodynamic equilibrium ( non-LTE ) models of the CO excitation were used to constrain the averaged gas density ( n ( { H _ { 2 } } ) \sim 10 ^ { 6 } cm ^ { -3 } ) in the cores ( i.e. , similar or lower than the critical densities for collisional thermalization of mid- and high- J CO levels ) . A uniform luminosity ratio , L { ( CO ) } / L _ { FIR } \sim ( 1 - 3 ) \times 10 ^ { -4 } , is measured along the extended envelope , suggesting that the same mechanism dominates the heating of the molecular gas at large scales . Conclusions : Sgr B2 shows extended emission from warm CO gas and cold dust , whereas only the cores show a hotter CO component . The detection of high-density molecular tracers and of strong [ N ii ] 205 \mu m line emission towards the cores suggests that their morphology must be clumpy to allow UV radiation to escape from the inner H ii regions . Together with shocks , the strong UV radiation field is likely responsible for the heating of the hot CO component . At larger scales , photodissociation regions ( PDR ) models can explain both the observed CO line ratios and the uniform L { ( CO ) } / L _ { FIR } luminosity ratios .