X-ray diffraction multipole refinements of single-crystalline MgxAl1−xB2 and polarizationdependent near-edge x-ray absorption fine structure at the B 1s edge reveal a strongly anisotropic electronic structure. Comparing the data for superconducting compounds (x = 0.8, 1.0) with those for the non-superconductor (x = 0) gives direct evidence for a rearrangement of the hybridizations of the boron pz bonds and underline the importance of holes in the σ-bonded covalent sp 2 states for the superconducting properties of the diborides. The data indicate that Mg is approximately divalent in MgB2 and suggest predominantly ionic bonds between the Mg ions and the two-dimensional B rings. For AlB2 (x = 0), on the other hand, about 1.5 electrons per Al atom are transferred to the B sheets while the residual 1.5 electrons remain at the Al site which suggests significant covalent bonding between the Al ions and the B sheets. This finding together with the static electron deformation density points to almost equivalent electron counts on B sheets of MgB2 and AlB2, yet with a completely different electron/hole distribution between the σ and π bonds.