  With the increase of the lattice distortion, the orthorhombic manganites
$R$MnO$_3$ ($R$$=$ La, Pr, Nd, Tb, and Ho) are known to undergo the phase
transition from the layered A-type antiferromagnetic (AFM) state to the zigzag
E-type AFM state. We consider the microscopic origin of this transition. Our
approach consists of the two parts. First, we construct an effective lattice
fermion model for the manganese 3d-bands and derive parameters of this model
from the first-principles electronic structure calculations. Then, we solve
this model in the Hartree-Fock approximation (HFA) and analyze the behavior of
interatomic magnetic interactions. We argue that the nearest-neighbor
interactions decrease with the distortion and at certain stage start to compete
with the longer range (particularly, second- and third-neighbor) AFM
interactions in the orthorhombic ab-plane, which lead to the formation of the
E-phase. The origin of these interactions is closely related to the orbital
ordering, which takes place in the distorted orthorhombic structure. The model
is able to capture the experimental trend and explain why LaMnO$_3$ develops
the A-type AFM order and why it tends to transform to the E-type AFM order in
the more distorted compounds. Nevertheless, the quantitative agreement with the
experimental data crucially depends on other factors, such as the magnetic
polarization of the oxygen sites and the correlation interactions beyond HFA.
