Phones can typically provide location information to different levels of accuracy (configured in settings).
Network-based location approximates the location by combining the known locations of mobile network cell tower sites with information such as signal timings.
GPS (Global Positioning System) relies on radio signals received from a network of satellites orbiting the earth. GPS requires line of sight to GPS satellites, i.e. outdoors (or at least near a large window). Phones analyze the signals from a number of satellites with some geometry to accurately determine your location. GPS uses quite a lot of power (hence phone battery).
Cell phones use A-GPS (network assisted GPS) to help shorten the time to fix onto satellites and to improve accuracy. A cell phone with no network connection will not have the benefit of this assistance (e.g. the network can’t provide GPS satellite orbital data to reduce the time to fix onto a GPS satellite).
GPS satellites are owned by the United States government. Many phones support other GPS-like satellite networks, including GLONASS (Russian), BDS (China) and GALILEO (Europe).