Internet of Things (IoT) is a global network of physical objects interacting over the Internet using distinctive address schemes. As IoT devices are mobile and heterogeneous with limited resources, security mechanisms in IoT routing protocols are crucial. The standard IoT routing protocol, the Routing Protocol for Low-power and Lossy Networks (RPL) offers minimal defense against routing attacks. We propose a mobility-aware secure trust-based routing protocol for RPL-based IoT (MSecTrust) to prevent the consequences of routing attacks. MsecTrust calculates the trust values based on the Dempster-Shafer theory for secure routing path selection. To overcome the drawbacks of using only one metric, MSecTrust uses a combination of metrics, including mobility-related characteristics, for the best parent node selection. The proposed protocol also incorporates necessary countermeasures to routing attacks such as blackhole attacks and rank attacks. The simulation results show that the proposed MSecTrust outperforms earlier studies regarding the average number of node rank changes, packet loss ratio, throughput, and average power consumption. In the experimental results, the average packet loss ratio of the proposed MSecTrust is 14.7% under blackhole attack and 13.2% under rank attack, which is relatively low compared to existing approaches. Similarly, the proposed MSecTrust shows 1.28% and 1.68% improvement in throughput under blackhole and rank attack respectively.