Magnetic tunnel junctions (MTJs) constitute a promising building block for future nonvolatile memories and logic circuits. Despite their pivotal role, spatially resolving and chemically identifying each individual stacking layer remains challenging due to spatially localized features that complicate characterizations limiting understanding of the physics of MTJs. Here, we combine advanced electron microscopy, spectroscopy, and first-principles calculations to obtain a direct structural and chemical imaging of the atomically confined layers in a CoFeB-MgO MTJ, and clarify atom diffusion and interface structures in the MTJ following annealing. The combined techniques demonstrate that B diffuses out of CoFeB electrodes into Ta interstitial sites rather than MgO after annealing, and CoFe bonds atomically to MgO grains with an epitaxial orientation relationship by forming Fe(Co)-O bonds, yet without incorporation of CoFe in MgO. These findings afford a comprehensive perspective on structure and chemistry of MTJs, helping to develop high-performance spintronic devices by atomistic design.