The motion and rotation of an ellipsoidal particle inside square tubes and rectangular tubes with the confinement ratio R/a∈(1.0,4.0) are studied by the lattice Boltzmann method (LBM), where R and a are the radius of the tube and the semi-major axis length of the ellipsoid, respectively. The Reynolds numbers (Re) up to 50 are considered. For the prolate ellipsoid inside square and rectangular tubes, three typical stable motion modes which depend on R/a are identified, namely, the kayaking mode, the tumbling mode, and the log-rolling mode are identified for the prolate spheroid. The diagonal plane strongly attracts the particle in square tubes with 1.2≤R/a<3.0. To explore the mechanism, some constrained cases are simulated. It is found that the tumbling mode in the diagonal plane is stable because the fluid force acting on the particle tends to diminish the small displacement and will bring it back to the plane. Inside rectangular tubes the particle will migrate to a middle plane between short walls instead of the diagonal plane. Through the comparisons between the initial unstable equilibrium motion state and terminal stable mode, it is seems that the particle tend to adopt the mode with smaller kinetic energy.