How Does A GPS Work?
Orbiting the earth are 27 satellites, however, only 24 are in operation (3 are used as spares in the case that one of the other 24 fails). They have been set to orbit the earth in such a way that at any instant from any position on the earth, at least 4 of the satellites are "visible" (Note: "visible" does not mean you can see them with your eye, but your GPS reciever can detect them).
Your GPS reciever is able to send and recieve signals from the satellites it has contact with, and by doing so, it is able to locate its exact position on the earth via a process known as trilateration. It does this by calculating the distance to each of the 4 (or more) satellites, and then uses this information to calculate its exact position.
Trilateration
Trilateration is the process by which a GPS reciever uses signals from orbiting satellites to locate its exact position on the earth. As mentioned above, a GPS reciever always has atleast 4 satellites within its reach, however only 3 are essential; the fourth adds an element of accuracy.
GPS recievers and satellites act in a 3-dimensional space. In a 3D space, trilateration can be a little hard to visualise, so to help explain it, first consider a 2-dimensional world. Lets pretend you are lost in the middle of nowhere, however, you have contact with people from point A and point B.
A person at point A tells you that you are 500 miles from where he is stationed. This helps us, but doesnt give us an exact picture of where we are, since we could lie anywhere on the circle centered at point A with radius 500 miles:

What if we introduce some extra information from another point? Lets say a person at point B tells us that we are 600 miles from them? Now, we could be anywhere on a circle centered at a point B with radius 600 miles, HOWEVER, the information from point A restricts this to only two points, since we must also be on the circle described by point A:

You must be on one of the two red dots, since they are the only points that are both 500 miles from A and 600 miles from B.
To narrow it down one final time, we get information from a person stationed at point C, who tells you that you are 200 miles from where he is. This narrows your possible location down to one point:

You must be on point C because it is the only place that corresponds to all of the information we have recieved from points A, B and C. Real trilateration in a 3D space (used by your GPS reciever), is exactly the same, however it works with spheres instead of circles, and a fourth satellite is used for increased accuracy.
Communication
We have established the basics behind how the GPS reciever can calculate its position knowing its distance from various satellites. Now the question remains, how exactly does it calculate its distance from the satellites?
At any specific moment, a satellite may start sending an electromagnetic signal to a GPS reciever. The signal consists of a pseudo-random code, a string of random digits. At the same moment, the GPS reciever begins producing the same code. Since the satellites are so far from the GPS reciever, there is a time delay between the GPS reciever's playing of the code and when the signal from the satellite reaches it. This time delay is equal to the time it takes for the signal to travel from the reciever to the satellite. Once this information has been calculated, it can be used to establish the distance between the GPS reciever and the satellite, by multiplying the time by the speed of light (the speed any electromagnetic wave travels at in a vacuum).
Stored within the GPS reciever is an almanac that tells it the exact position of every satellite at any moment (since the orbit of the satellites are very predicatble). This information together with the calculated distance between the satellite and GPS reciever can be used in the trilateration process to locate the GPS system's position on earth.
Differential GPS Systems
As you may be aware, the processes described above can induce errors in the calculations, making the GPS system less accurate. For example, the electromagnetic radio signal will not always be travelling at the speed of light as it travels through the ionosphere and troposphere, so this already leads to an innaccuracy in the calculation of the distance between the GPS reciever and satellite.
To account for such innaccuracies, your reciever may make use of the differential GPS system. Stationed at various positions on the earth (known positions) are systems that send out signals to all GPS recievers and correct errors.