Limestone is primarily composed of calcium carbonate, which is the main component of the shells and skeletons of many marine organisms like corals, mollusks, and foraminifera. Over millions of years, these skeletal remains accumulate on the ocean floor and are compacted and cemented together to form limestone.