Nowadays underwater wireless sensor networks (UWSNs) have gained a lot of attention. Among the services of UWSNs, localization and time synchronization have special importance. Usually localization and synchronization can be solved jointly. This could save energy of sensors which is a vital requirement in UWSNs. In this paper, a new robust iterative method based on least squares (LS) is proposed for joint localization and synchronization in UWSNs. In this method the stratification effect of underwater environment is considered and compensated. Indeed, the assumption of the straight line transmission in water medium could lead to considerable bias in the range estimation. Furthermore, by compensating the stratification effect, the sound speed can be calculated from a linear relationship; and this is one of the contributions of this article. The linear relationship for calculating the propagation speed is common in terrestrial networks, whereas the proposed method generalized it for underwater medium. In addition, as another contribution, iterative method is used to improve the accuracy of localization and time synchronization. The iteration process will continue until the position, skew and offset errors reached to the convergence. The proposed method has been compared with other benchmark joint localization and synchronization methods as well as the Cramér Rao Lower Bound (CRLB). The results show that the proposed method outperforms the benchmark methods and exhibits performance close to the CRLB.