The time it takes for the Earth to rotate on its axis 360 degrees, or one rotation relative to the "fixed" stars, is a Sidereal Day. (Sidereal means stars.) A Sidereal Day is 23 hours, 56 minutes and 4 seconds.By comparison, the time is takes for the Earth to rotate in such a way that the Sun goes from local noon to local noon is a Solar Day. Local noon is when the Sun is highest in the sky for an observer at a particular latitude. A Solar Day is also called an Earth Synodic Day.A Solar Day on average is 24 hours, although it can vary as much as plus or minus 25 seconds. The average Solar Day (24 hours) is called the Mean Solar Day.The four minute difference between the Sidereal Day and the Mean Solar Day has to do with the Earth moving forward in its orbit around the Sun as it rotates on its axis. Since the Earth moves forward in its orbit about a degree relative to the Sun each day, the Earth must rotate an extra degree (or 361 degrees total) each day to realign itself with the Sun for local noon to occur again.
The Sidereal Day is 4 minutes shorter than the Mean Solar Day, because the rotation of the Earth on its axis, and the orbiting of the Earth around the Sun, are both counterclockwise, as viewed from above (or north of) the Ecliptic Plane. See planetary retrograde motion for an example of the opposite situation.
The reason that the Solar Day varies around the Mean Solar Day is that the Earth moves at different speeds through its orbit around the Sun. This is in keeping with Kepler's Second Law of Planetary Motion.
Please note that the Mean Solar Day changes over a long period of time, due to the slowing of the rotation of the Earth due to tidal forces exerted on the Earth primarily by the Moon. For example, the Mean Solar Day was about 23 hours about 250 million years ago.