Walnut shell was pyrolyzed and then impregnated with NH4Br to make sorbent for Hg0 removal. The effect of flue gas components on Hg0 removal performance was studied in O2/CO2 atmosphere, and the results were compared with those in O2/N2 atmosphere. The mercury valence distribution during adsorption was obtained. NH4Br‐modified walnut shell coke promoted Hg0 removal, the Br‐containing chemisorption site was a crucial factor. Although addition of CO2 did not introduce new oxygen‐containing functional groups or change the mercury species, Hg0 removal efficiency increased significantly. This may be because CO2 can increase the active sites on the carbon surface. In O2/N2 atmosphere, O2 promoted formation of active center on the sorbent surface, which made Hg0 more easily adsorbed and then reacted with Br‐functional group to form more HgBr2. In O2/CO2 atmosphere, O2 promoted formation of some reactive carbon–oxygen complexes which acted as catalyst to facilitate Hg0 oxidation and formation of HgO. NO improved removal of Hg0, because the C─O functional group on the sorbent surface could catalyze the conversion of NO to NO2 in the adsorbed state and then formed Hg2(NO3)2. SO2 consumed oxygen on the sorbent surface and inhibited the Hg0 removal.