The Sanskrit term for gravity is ‘Gurutvakarshan’ (गुरुत्वाकर्षण) which is an amalgam of Guru-tva-akarshan. Guru means big (also master), ‘tva’ comes from ‘tvam’ means ‘you’ and ‘Akarshan’ means to be attracted, thus the meaning of Gurutvakarshan is to attract by big (master). Even if we look further it explains that the bigger object have the high gravitational force which attracts the smaller object (which has low gravitational force).
Now to the ancient scriptures:
“YadA suryamamun divi shukram jyotiradhArayah, maditte vishva bhuvanAni yemire"
It means ‘Oh Indra (all sustaining Lord) through establishing the all illuminating and powerful sun you maintain control over all cosmic bodies through mutual forces.’
This demonstrates that all the constellations are maintained and controlled by mutual energy.
Savita Yantraih Prithiveem Aramnaat Dyaam Andahat Atoorte Baddham Ashwam Iv Adhukshat
[Rig Veda 10.149.1]
It means “The sun has tied Earth and other planets through attraction and moves them around itself as if a trainer moves newly trained horses around itself holding their reins.”
The gravitational effect of solar system makes the earth stable also mentioned in Rig Veda 1-103-2, 1-115-4 and 5-81-2.
In Surya Siddhanta, dated 400-500 AD, the ancient Hindu astronomer Bhaskaracharya states-
“madhye samantandasya bhugolo vyomni tisthati
bibhranah paramam saktim brahmano dharanatmikam”
[Surya Sidhantha 12th chapter 32 sloka]
This means: “In the midst of universe (Brahmanda), the spherical earth stands firm in the space, because of the dharanatmika sakti, Earth is standing firm in the space without falling away.”
“akrsta saktisca mahi taya yat svastham guru svabhimukham svasaktya
akrsyate tatpatativa bhati same samantat kva patatviyam khe”
[Sidhanta Shiromani, Bhuvanakosa, 6th sloka]
This means: "Objects fall on the earth due to a force of attraction by the earth. Therefore, the earth, planets, constellations, moon, and sun are held in orbit due to this force."
Even before that the famous Indian mathematician Brahmagupta, in the 7th century had said about gravity that "Bodies fall towards the Earth as it is in the nature of the Earth to attract bodies, just as it is in the nature of water to flow". – Brahmasphuta Siddhanta.
About a hundred years before Brahmagupta, another astronomer, Varahamihira had claimed for the first time perhaps that there should be a force which might be keeping bodies stuck to the Earth, and also keeping heavenly bodies in their determined places. Thus the concept of the existence of some attractive force that governs the falling of objects to the Earth and their remaining stationary after having once fallen; as also determining the positions which heavenly bodies occupy, was recognized. It was also recognized that this force is attractive force.
Approximately 1200 years later (1687 AD) after Bhaskaracharya , Sir Isaac Newton rediscovered this phenomenon and called it the Law of Gravity.