The role of valence electrons for formation of glassy alloys was investigated as a function of their valence electron concentration (VEC). The glass transition temperature T g of 121 kinds of glassy alloys can be expressed as a linear function of VEC: T g =131VEC+65 (2.3<VEC<5.2) for metal/metal bonding type and T g =−240VEC+2408 (6.6<VEC<9.1) for metal/metalloid bonding one. The thermal stability of the glassy alloys increases by the unsynchronized resonance of electron-pair bonds, and decreases due to increase in covalency by metalloid elements, with an increasing number of valence electrons, respectively. Ab initio molecular orbital calculations of the optimized structures for the Mg monoanion clusters warranted application of the valence electron rule, which is based on a valence electron contribution associated with spd or spf hybridization for glass formation.