Perhaps the reason for prohibition was that their dead ones...
Perhaps the reason for prohibition was that their dead ones were predominantly polytheists and idol-worshippers and Islam had cut off their relation and affection with the world of polytheism. It is also possible that the reason for prohibition was something else and that is the newly converted Muslims were writing elegies and saying un-Islamic things over the graves of the dead polytheists.
But after the expansion of Islam and the ‘faith’ entering into the hearts of people, this prohibition was lifted and the Holy Prophet (s) permitted the people to go for the ziyarat of graves because of the educative benefits, so that people should hasten to visit graves The writers of Sunan and Sihah narrate as such: كُنت نهيتكم عن زيارة القُبور فزُوروها فإنها تُزهِّد في الدنيا وتُذكر الأخرة “I had prohibited you from ziyara of graves. From now on, go for…