In two-way time-of-arrival (TOA) systems, a user device (UD) obtains its position and timing information by roundtrip communications to a number of anchor nodes (ANs) at known locations. Compared with the one-way TOA technique, the two-way TOA scheme is easy to implement and has better localization and synchronization accuracy. Existing two-way TOA localization and synchronization methods assume a stationary UD. This will cause uncompensated position and timing errors. In this article, we propose an optimal maximum likelihood (ML) based two-way TOA localization and synchronization method, namely TWLAS, which takes the UD motion into account to compensate the error caused by the UD movement. We analyze its estimation error and derive the Cramér-Rao lower bound (CRLB). We show that the conventional two-way TOA method is a special case of the TWLAS when the UD is stationary, and the TWLAS has better estimation accuracy than the conventional one-way TOA method. We also derive the estimation error in the case of deviated UD velocity information. Numerical result demonstrates that the estimation accuracy of the new TWLAS for a moving UD reaches CRLB, better than that of the conventional one-way TOA method, and the estimation error caused by the deviated UD velocity information is consistent with the theoretical analysis.