Google does not take the IP address into account when identifying users.
IP addresses are often dynamically assigned and can change between visits (or even during a visit - in ancient times AOL had a nasty habit of reassigned IPs during visits), so by themselves they would be not sufficient to recognize a recurring user.
Also there might be legal problems - some jurisdictions (e.g. Germany) consider IP addresses personally identifiable information and require that they are anonymized before data processing takes place.
Some Analytics software (e.g. Piwik) still use the IP address to create a "fingerprint" for a user. FWIW, at the "Analytics Summit" in Hamburg/Germany 2016 Google employee Oliver Borm said that Google does not, and will never do, use fingerprinting ( I don't know if he had actual authority to issue blanket statements on Google's behalf, though).
Instead pageviews are aggregated into sessions, and sessions aggregated into users, by use of a client id. If you use the Javascript tracker the client id generated by the JS code and stored in a cookie named _ga.
One of the reasons Google uses Javascript injection to load the tracking code is that this makes the code run in page context, so it can set first party cookies on your domain. If the cookie was set by the Google server you'd have a third party cookie, which would be blocked by many browsers.
Pageviews with the same clientId within 30 minutes without inactivity (customizable to up to four hours) will be aggregated into a session (sessions also end when the campaign attribution changes, after 500 interaction hits, when they are programmatically terminated by the tracking code, and all sessions end at midnight).
Sessions that are calculated with the same client id are aggregated into the unique user metric.
The _ga cookie that stores the client id has a lifetime of two years, but is updated on each visit (so as long as the users returns within two years cookie lifetime is indefinite for practical purposes). Some of the cookie settings can be customized as documented here. You can also use localstorage as an alternative storing mechanism, or even supply your own client id when you create the tracker (i.e. a value that is created and persisted on your server).
Google does not actually care that much about the format of the clientId, but recommends something along the line of a UUID, since the clientId must be unique per visitor.