Muslims revere the compound in Ayodhya, north India, as the site of the now-demolished 16th century Babri Mosque, while Hindus say it is the birthplace of the god Rama.
The Allahabad High Court ruled that the site should be split, with the Muslim community getting control of one-third and two Hindu groups splitting the remainder, according to Ravi Shankar Prasad, a lawyer for one of the parties to the suit.
The Hindus will keep the area where a small tent-shrine to Rama has been erected, he said.
"The majority ruled that the location of the makeshift temple is the birthplace of Rama, and this spot cannot be shifted," he said.
The court also ruled that the current status of the site should continue for the next three months to allow for the land to be peacefully measured and divided, he said.
Thousands of paramilitary and riot police have been deployed in India as the country was braced for violence following the ruling.
Ever since the destruction of the mosque 18 years ago the site has been cordoned off with barbed wire and steel fencing and guarded by troops.
A total of 200,000 police and paramilitary forces patrolled the streets of Uttar Pradesh on Thursday, with tens of thousands on special duty in other areas around the country that are vulnerable to religious clashes.
The full verdict of the bench hearing the case has not yet been released to the public.