In layered magnetic materials, the magnetic coupling between neighboring van der Waals layers is challenging to understand and anticipate, although the exchange interaction inside a layer can be well rationalized for example by the superexchange mechanism. In this work, we elucidate the interlayer exchange mechanism and propose an electron-counting rule to determine the interlayer magnetic order between van der Waals layers, based on counting the d-orbital occupation (dn, where n is the number of d-electrons at the magnetic cation). With this rule, we classify magnetic monolayers into two groups, type-I () and type-II (n ≥ 5), and derive three types of interlayer magnetic coupling for both insulators and metals. The coupling between two type-II layers prefers the antiferromagnetic (AFM) order, while type-I and type-II interface favors the ferromagnetic (FM) way. However, for two type-I layers, they display a competition between FM and AFM orders and even lead to the stacking dependent magnetism. Additionally, metallic layers can also be incorporated into this rule with a minor correction from the free carrier hopping. Therefore, this rule provides a simple guidance to understand the interlayer exchange and further design van der Waals junctions with desired magnetic orders.