In the Ptolemaic system of astronomy, the epicycle (literally: on the circle in Greek) was a geometric model used to explain the variations in speed and direction of the apparent motion of the Moon, Sun, and planets. It was first proposed by Apollonius of Perga at the end of the 3rd century BC and formalized by Ptolemy of the Thebaid in his 2nd-century AD astronomical treatise the Almagest. In particular it explained the retrograde motion of the five planets known at the time. Secondarily, it also explained changes in the apparent distances of the planets from Earth.

It is called Ptolemaic after the Greek astronomer Ptolemy, although it had been developed by previous Greek astronomers such as Apollonius of Perga and Hipparchus of Rhodes, who used it extensively, almost five centuries before Ptolemy. Epicyclical motion is used in the Antikythera Mechanism, an ancient Greek astronomical device for computing the phase and position of the Moon using four gears, two of them engaged in an eccentric way that closely approximates Kepler's second law, i.e. the Moon moves faster at perigee and slower at apogee.

In the Ptolemaic system, the planets are assumed to move in a small circle called an epicycle, which in turn moves along a larger circle called a deferent. Both circles rotate eastward and are roughly parallel to the plane of the Sun's orbit (ecliptic). The orbits of planets in this system are epitrochoids.

Despite the fact that the Ptolemaic system is considered geocentric, the planets' motion was not thought to be actually centered on the Earth. Instead, the deferent was centered around a point halfway between the Earth and another point called the equant. The epicycle, meanwhile, rotated and revolved along the deferent with uniform motion. The rate at which the planet moved on the epicycle was fixed such that the angle between the center of the epicycle and the planet was the same as the angle between the earth and the sun.

Ptolemy did not predict the relative sizes of the planetary deferents in the Almagest. All of his calculations were done with respect to a normalized deferent. This is not to say that he believed the planets were all equidistant. He did guess at an ordering of the planets. Later he calculated their distances in the Planetary Hypotheses.

For superior planets the planet would typically move through in the night sky slower than the stars. Each night the planet would "lag" a little behind the star. This is prograde motion. Occasionally, near opposition, the planet would appear to move through in the night sky faster than the stars. This is retrograde motion. Ptolemy's model, in part, sought to explain this behavior.

The inferior planets were always observed to be near the sun, appearing only shortly before sunrise or shortly after sunset. To accommodate this, Ptolemy's model fixed the motion of Mercury and Venus so that the line from the equant point to the center of the epicycle was always parallel to the earth-sun line.