Metaphysics is a major branch of philosophy. It concerns existence and the nature of things that exist. Altogether it is a theory of reality.
Ontology is the part of metaphysics which discusses what exists: the categories of being. Apart from ontology, metaphysics concerns the nature of, and relations among, the things that exist.
The metaphysical idea that reality exists independently of one’s mind and yet can be known is called realism. The metaphysical idea that no mind-independent reality exists or can be known is idealism. These are two main battlegrounds of metaphysics.
In the West, metaphysics is usually traced to the natural philosophers in ancient Greece, where Aristotle systematized a metaphysical description of nature equivalent to today’s theoretical science.
By the 4th century AD in Alexandria, Egypt, alchemy was starting its transformation into chemistry. The conventional view is that alchemy was steeped in mysticism, and that chemistry did not quite become what we would call science until it entered the 19th century.
In the early 17th century, Galileo introduced to physics his experiments with earthly objects: the dawn of empirical science in Western Europe. Galilean laws of motion led to the overthrow of Aristotle’s ideas, a revolution more or less completed by the wide acceptance of Cartesian physics, built upon Copernican and Galilean mechanics.
Newtonian physics rapidly replaced Cartesian physics. Isaac Newton, like others that we now call scientists, was known as a natural philosopher. In the 1830s, Auguste Comte created positivism, the first modern philosophy of science. It sought the divorce of science from religion and metaphysics.
In 1847, Hermann von Helmholtz’s paper “On the conservation of energy”, stated the first law of thermodynamics, and tried to reduce physiology to physics. In 1859, Darwin proposed an explanation of evolution by natural selection. Both seemed plausible and compatible with physical theory.
By the 1860s, the term science (as meaning something distinct from philosophy) entered the dictionary. Today the term metaphysics usually refers to discussion of aspects of reality which are beyond physics. Particularly among those seeking to be scientific, the term metaphysics can be pejorative to varying degrees. However, philosophers of science recognize that science is impossible without metaphysics. At the very least, before beginning empirical investigation, one needs an ontology. This is because categories are needed to sort observations into.