The tides on Earth are caused mostly by the moon—although the sun has a small effect. Here's how it works.
The moon's gravity pulls on the oceans. Therefore, high tide stays aligned with the moon as the Earth spins underneath. Another high tide occurs on the opposite side of the planet because gravity pulls the Earth itself toward the moon more than it pulls the water.
At the full moon and new moon, the sun, Earth, and moon are lined up, producing higher than normal tides (called spring tides, for the way they spring up). When the moon is at first or last quarter, smaller tides than normal form. These are called neap tides. The moon's 29.5-day orbit around Earth is not quite circular. When the moon's orbit brings it closest to Earth, spring tides are even higher, and they're called perigean spring tides.
All this tugging has another interesting effect: Some of Earth's rotational energy is stolen by the moon, causing our planet's rotation to slow down by about 1.5 milliseconds every century.