Localizing machine-type communication (MTC) devices or sensors is becoming important because of the increasing popularity of machine-to-machine (M2M) communication networks for location-based applications. These include such as health monitoring, rescue operations, vehicle tracking, and wildfire monitoring. Moreover, efficient localization approaches for sensor-based MTC devices reduce the localization error and energy consumption of MTC devices. Because sensors are used as an integral part of M2M communication networks and have achieved popularity in underwater applications, research is being conducted on sensor localization in both underwater and terrestrial M2M networks. Major challenges in designing underwater localization techniques are the lack of good radio signal propagation in underwater, sensor mobility management, and ensuring network coverage in 3D underwater M2M networks. Similarly, predicting the mobility pattern of MTC devices, trading-off energy consumption and location accuracy pose great design challenges for terrestrial localization techniques. This article presents a comprehensive survey on the current state-of-the-art research on both terrestrial and underwater localization approaches for sensor-based MTC devices. It also classifies localization approaches based on several factors, identifies their limitations with potential solutions, and compares them.