The recent advances in low earth orbit (LEO) satellites enable the satellites to provide task processing capability for remote Internet-of-Things (IoT) mobile devices (IMDs) without proximal multiaccess edge computing (MEC) servers. In this article, by leveraging the LEO satellites, a novel MEC framework for terrestrial-satellite IoT is proposed. With the aid of terrestrial-satellite terminal (TST), the computation offloading from IMDs to LEO satellites is divided into two stages in the ground and space segments. In order to minimize the weighted-sum energy consumption of IMDs, we decompose the formulated problem into two layered subproblems: 1) the lower layer subproblem minimizing the latency of space segment, which is solved by sequential fractional programming with attaining the first-order optimality and 2) the upper layer subproblem that is solved by exploiting the convex structure and applying the Lagrangian dual decomposition method. Based on the solutions to the two layered subproblems, an energy-efficient computation offloading and resource allocation algorithm (E-CORA) is proposed. By simulations, it is shown that: 1) there exists a specific amount of offloading bits, which can minimize the energy consumption of IMDs and the proposed E-CORA outperforms full offloading and local computing only; 2) larger transmit power of the TST helps to save the energy of IMDs; and 3) by increasing the number of visible satellites, the ratio of offloading bits increases while the energy consumption of IMDs can be decreased.