This paper reports the relationship between the heat treatments of the CoFeB/MgO/CoFeB/Ta-based magnetic tunnel junction (MTJ) and the chemical bonding state using angle-resolved hard X-ray photoelectron spectroscopy. The redox reaction for B 1s during postannealing was verified for the MTJ without a capping layer by oxidizing the metallic B 1s in CoFeB and reducing the oxidized Fe 2p and Co 2p near the surface. For the MTJ with a capping layer, regardless of the heat treatments, MgO was found to be in a peroxidized state, and the diffusion of O 1s and B 1s exerted by the heat treatments is considered to be controlled by the degree of crystallization of MgO. The composition at the MgO/CoFeB interface changes on account of the heat treatments since the ratio of CoFeB and TaB at the bottom changes as a result of boron diffusion through the grain boundaries in MgO. By postannealing at 400 °C, the peak binding energy of Mg 1s at the surface was found to shift slightly to lower energy toward the stoichiometric MgO. However, the release of the excess oxygen in MgO is suppressed by the crystallization. Since the crystallization of MgO is enhanced by the in situ IR heating, the internal oxygen is more constrained in MgO. An improvement of the tunneling magnetoresistance deterioration observed with an ultrathin MgO is considered to be achieved under the peroxidized state controlled by the crystallinity of MgO.