In the 4th century BC, the Greek philosopher Aristotle believed that there is no effect or motion without a cause. The cause of the downward motion of heavy bodies, such as the element earth, was related to their nature, which caused them to move downward toward the center of the universe, which was their natural place. Conversely, light bodies such as the element fire, move by their nature upward toward the inner surface of the sphere of the Moon. Thus in Aristotle's system heavy bodies are not attracted to the Earth by an external force of gravity, but tend toward the center of the universe because of an inner gravitas or heaviness.
If the quicksilver is poured into a vessel, and a stone weighing one hundred pounds is laid upon it, the stone swims on the surface, and cannot depress the liquid, nor break through, nor separate it. If we remove the hundred pound weight, and put on a scruple of gold, it will not swim, but will sink to the bottom of its own accord. Hence, it is undeniable that the gravity of a substance depends not on the amount of its weight, but on its nature. 
Aryabhata first identified the force to explain why objects do not fall when the earth rotates,and developed a geocentric solar system of gravitation, with an eccentric elliptical model of the planets, where the planets spin on their axes and follow elliptical orbits,the Sun and the moon revolving around the earth in epicycles. Indian astronomer and mathematician Brahmagupta described gravity as an attractive force and used the term " gurutvākarṣaṇ " for gravity.  
"Disregarding this, we say that the earth on all its sides is the same; all people on the earth stand upright, and all heavy things fall down to the earth by a law of nature, for it is the nature of the earth to attract and to keep things, as it is the nature of water to flow, that of fire to burn, and that of the wind to set in motion. If a thing wants to go deeper down than the earth, let it try. The earth is the only low thing, and seeds always return to it, in whatever direction you may throw them away, and never rise upwards from the earth."  
During the 17th century, Galileo found that, counter to Aristotle's teachings, all objects accelerated equally when falling.
In the late 17th century, as a result of Robert Hooke's suggestion that there is a gravitational force which depends on the inverse square of the distance, Isaac Newton was able to mathematically derive Kepler's three kinematic laws of planetary motion, including the elliptical orbits for the six then known planets and the Moon:
"I deduced that the forces which keep the planets in their orbs must be reciprocally as the squares of their distances from the centres about which they revolve, and thereby compared the force requisite to keep the moon in her orb with the force of gravity at the surface of the earth and found them to answer pretty nearly."— Isaac Newton, 1666
So Newton's original formula was:
where the symbol means "is proportional to".
To make this into an equal-sided formula or equation, there needed to be a multiplying factor or constant that would give the correct force of gravity no matter the value of the masses or distance between them. This gravitational constant was first measured in 1797 by Henry Cavendish.
In 1907 Albert Einstein, in what was described by him as " the happiest thought of my life ", realized that an observer who is falling from the roof of a house experiences no gravitational field. In other words, gravitation was exactly equivalent to acceleration. Between 1911 and 1915 this idea, initially stated as the equivalence principle, was formally developed into Einstein's theory of general relativity.
Newton's theory of gravitation
In 1687, English mathematician Sir Isaac Newton published Principia , which hypothesizes the inverse-square law of universal gravitation. In his own words, "I deduced that the forces which keep the planets in their orbs must be reciprocally as the squares of their distances from the centers about which they revolve; and thereby compared the force requisite to keep the Moon in her orb with the force of gravity at the surface of the Earth; and found them answer pretty nearly."
Newton's theory enjoyed its greatest success when it was used to predict the existence of Neptune based on motions of Uranus that could not be accounted by the actions of the other planets. Calculations by John Couch Adams and Urbain Le Verrier both predicted the general position of the planet, and Le Verrier's calculations are what led Johann Gottfried Galle to the discovery of Neptune.
Years later, it was another discrepancy in a planet's orbit that showed Newton's theory to be inaccurate. By the end of the 19th century, it was known that the orbit of Mercury could not be accounted for entirely under Newtonian gravity, and all searches for another perturbing body (such as a planet orbiting the Sun even closer than Mercury) have been fruitless. This issue was resolved in 1915 by Albert Einstein's new general theory of relativity, which accounted for the discrepancy in Mercury's orbit.
Paul Dirac developed the hypothesis that gravitation should have slowly and steadily decreased over the course of the history of the universe.
Although Newton's theory has been superseded, most modern non-relativistic gravitational calculations still use it because it is much easier to work with and is sufficiently accurate for most applications.
Mechanical explanations of gravitation
The mechanical theories or explanations of the gravitation are attempts to explain the law of gravity by aid of basic mechanical processes, such as pushes, and without the use of any action at a distance. These theories were developed from the 16th until the 19th century in connection with the aether theories.
René Descartes (1644) and Christiaan Huygens (1690) used vortices to explain gravitation. Robert Hooke (1671) and James Challis (1869) assumed, that every body emits waves which lead to an attraction of other bodies. Nicolas Fatio de Duillier (1690) and Georges-Louis Le Sage (1748) proposed a corpuscular model, using some sort of screening or shadowing mechanism. Later a similar model was created by Hendrik Lorentz, who used electromagnetic radiation instead of the corpuscles. Isaac Newton (1675) and Bernhard Riemann (1853) argued that aether streams carry all bodies to each other. Newton (1717) and Leonhard Euler (1760) proposed a model, in which the aether loses density near the masses, leading to a net force directing to the bodies. Lord Kelvin (1871) proposed that every body pulsates, which might be an explanation of gravitation and the electric charges.
However, those models were overthrown because most of them lead to an unacceptable amount of drag, which is not observed. Other models are violating the energy conservation law and are incompatible with modern thermodynamics. 
In general relativity , the effects of gravitation are ascribed to spacetime curvature instead of to a force. The starting point for general relativity is the equivalence principle, which equates free fall with inertial motion. The issue that this creates is that free-falling objects can accelerate with respect to each other. In Newtonian physics, no such acceleration can occur unless at least one of the objects is being operated on by a force (and therefore is not moving inertially).
To deal with this difficulty, Einstein proposed that spacetime is curved by matter, and that free-falling objects are moving along locally straight paths in curved spacetime. (This type of path is called a geodesic). More specifically, Einstein and Hilbert discovered the field equations of general relativity, which relate the presence of matter and the curvature of spacetime and are named after Einstein. The Einstein field equations are a set of 10 simultaneous, non-linear, differential equations. The solutions of the field equations are the components of the metric tensor of spacetime. A metric tensor describes the geometry of spacetime. The geodesic paths for a spacetime are calculated from the metric tensor.
Notable solutions of the Einstein field equations include:
- The Schwarzschild solution, which describes spacetime surrounding a spherically symmetric non- rotating uncharged massive object. For compact enough objects, this solution generated a black hole with a central singularity. For radial distances from the center which are much greater than the Schwarzschild radius, the accelerations predicted by the Schwarzschild solution are practically identical to those predicted by Newton's theory of gravity.
- The Reissner–Nordström solution, in which the central object has an electrical charge. For charges with a geometrized length which are less than the geometrized length of the mass of the object, this solution produces black holes with an event horizon surrounding a Cauchy horizon.
- The Kerr solution for rotating massive objects. This solution also produces black holes with multiple horizons.
- The cosmological Robertson–Walker solution, which predicts the expansion of the universe.
General relativity has enjoyed much success because of the way its predictions of phenomena which are not called for by the older theory of gravity have been regularly confirmed. For example:
- General relativity accounts for the anomalous perihelion precession of the planet Mercury.
- The prediction that time runs slower at lower potentials has been confirmed by the Pound–Rebka experiment, the Hafele–Keating experiment, and the GPS.
- The prediction of the deflection of light was first confirmed by Arthur Eddington in 1919, and has more recently been strongly confirmed through the use of a quasar which passes behind the Sun as seen from the Earth. See also gravitational lensing.
- The time delay of light passing close to a massive object was first identified by Irwin Shapiro in 1964 in interplanetary spacecraft signals.
- Gravitational radiation has been indirectly confirmed through studies of binary pulsars. In 2016, the LIGO experiments directly detected gravitational radiation from two colliding black holes, making this the first direct observation of both the gravitational radiation as well as black holes.
- The expansion of the universe (predicted by the Robertson–Walker metric) was confirmed by Edwin Hubble in 1929.
Gravity and quantum mechanics
Several decades after the discovery of general relativity it was realized that it cannot be the complete theory of gravity because it is incompatible with quantum mechanics. Later it was understood that it is possible to describe gravity in the framework of quantum field theory like the other fundamental forces. In this framework the attractive force of gravity arises due to exchange of virtual gravitons, in the same way as the electromagnetic force arises from exchange of virtual photons. This reproduces general relativity in the classical limit, but only at the linearized level and postulating that the conditions for the applicability of Ehrenfest theorem holds, which is not always the case. Besides, this approach fails at short distances of the order of the Planck length.
It is notable that in general relativity, gravitational radiation, which under the rules of quantum mechanics must be composed of gravitons, is created only in situations where the curvature of spacetime is oscillating, such as is the case with co-orbiting objects. The amount of gravitational radiation emitted by the solar system is far too small to measure.
However, gravitational radiation has been observed both indirectly, as an energy loss over time in binary pulsar systems such as PSR 1913+16, and directly by the LIGO gravitational wave observatory, whose first detection (named GW150914) occurred on 14 September 2015  and matched theoretical predictions of signals due to the inward spiral and merger of a pair of black holes. It is believed that neutron star mergers (since detected in 2017)  and black hole formation may also create detectable amounts of gravitational radiation.