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.
Satellite-based location (high accuracy) relies on radio signals received from a network of satellites orbiting the earth.
There are a number of global and regional satellite systems. GPS (Global Positioning System) satellites are owned by the United States government. Many phones support other satellite systems, including GLONASS (Russia), BeiDou (China), Galileo (Europe) and QZSS (Japan). Phones may use a combination of satellites from different systems to obtain a position fix (e.g. GPS and Glonass).
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).