A mechanical pipe organ was first used by the Ancient Greeks. This early organ, called a hydraulis, was more of a set of pan pipes with airflow driven by water pressure.
By the 7th century, bellows began to be used to supply the needed airflow or “wind” to make a sound. By the 12th century, the organ began to evolve into a complex instrument capable of producing different timbres and by the 17th century, most of the sounds available on the modern classical organ had been developed.
Check out this exploded view of a pipe organ to learn more: