Is it true that we all met Allah as souls before being born? That some souls prostrated to Allah whilst others did not?
And that the souls we met there we naturally like here on earth and feel like we`ve known each other forever?
I see many people saying this and want to verify references and if it is true.
In the Name of Allah, the Most Gracious, the Most Merciful.
As-salāmu ‘alaykum wa-rahmatullāhi wa-barakātuh.
Allah Ta`ala states in the Glorious Qur`an [7: 172]:
وإذ أخذ ربك من بني آدم من ظهورهم ذريتهم وأشهدهم على أنفسهم ألست بربكم قالوا بلى شهدنا أن تقولوا يوم القيامة إنا كنا عن هذا غافلين
Translation: And, remember, when your Lord took from the Children of Adam, from their backs their progeny, and made them testify about themselves, saying, ‘Am I not your Lord?’ They said, ‘Yes, indeed, we testify’, lest you should say on the Day of Resurrection, ‘Truly,we were unaware of this.’
According to Imam Raghib al-Asfahani, the word “Zurriyyah” (progeny) in the Glorious Qur`an signifies all those created and denotes that this covenant of Eternity encompassed all the human beings since they constitute the progeny of Adam (peace be upon him). Ibn Abbas and Ubayy ibn Ka`b narrate and Abu Hurairah (may Allah be pleased with them all) relates from Allah`s Messengers (peace be upon him) that Allah brought forth every human being to be born till the Day of Judgement and they all testified to the oneness of Allah and consequently made this covenant with Him.
It is recorded in al-Muwatta li al-Imam Malik , Sunan Abi Dawud , Sunan an-Nasa`I , Sunan at-Tirmidhi  and Musnad al-Imam Ahmad  that Prophet Muhammad (peace be upon him) said:
“Allah Almighty first created Adam (peace be upon him), then He placed His hand upon his back, and drew forth all the righteous descendants of Adam who were to come into being and said, “I have created them for the Paradise, and they shall act righteously as to deserve Paradise. Then He placed His hand on the back of Adam and all the wicked descendants that were to come into being appeared. He said, “I have created them for the Hell, and they shall act wickedly as to lead them to Hell.”
Someone from among the companions of the Prophet of Allah (peace be upon him) asked him, “When Allah has already decided the fate of the mankind why the people are asked to do good deeds, while they are of no effect. The Holy Prophet (peace be upon him) said, “Whoever is created for Paradise, he starts doing good deeds making him worthy of paradise and he dies in this state, while the one created for the Hell involves himself in wicked acts making him liable of the fires of Hell until he dies doing such deeds as leads him to the Hell.”
Furthermore, Abu Darda (may Allah be pleased with him) narrates that the people appeared in the size of small ants. It is reported from Abu Darda and Maqatil (May Allah be pleased with them both) that those who appeared the first time were of fair colour while those appearing the second time were black. Additionally, Abu Hurairah (may Allah be pleased with him) reports that all the children of Adam who were to come in the world up to the end of time had a kind of brilliance on their foreheads.
There have been individuals who remembered the occasion of this covenant. Dhul Nun al-Misri (may Allah have His mercy upon him), a great spiritual leader, states, “I remember the occurrence of this covenant as clearly as I am hearing it this very moment.” Mufti Muhammad Shafi` (may Allah have His mercy upon him) expounds that some elders have even reported to have remembered even the people who were present near them. Hadhrat Ali (karrama Allahu wajhahu) states, “Truly, I remember the covenant my Lord took from me” and Sahl at-Tustari (may Allah have His mercy upon him) would say, “I recognise my students from that day [of covenant] and I was shown them in the loins until they reached me.”
In regards to your query pertaining to the familiarity between individuals based on the encounter between souls before being born, Prophet Muhammad (peace be upon him) said:
الأرواح جنود مجندة فما تعارف منها ائتلف و ما تناكر منها اختلف
Translation: Souls are like conscripted soldiers; those whom they recognize, they get along with, and those whom they do not recognize, they will not get along with.
In the explanation to this Hadith, the two famous commentators of Sahih al-Bukhari, Abu Muhammad Mahmud bin Ahmad al-Aini and Ahmad bin Ali ibn Hajar al-Asqalani, expound:
أنه روي أن الله تعالى خلق الأرواح قبل الأجساد وكانت تلتقي، فلما التبست بالأجساد تعارفت بالذكر الأول فصار كل واحد منها إنما يعرف وينكر على ما سبق له من العهد المتقدم
Translation: It is narrated that Allah (Exalted is He) created the souls before the bodies, and they would meet one another. When they became mixed in with the bodies, they gained familiarity with one another based on the earlier memory. Then each one of them began to show approval and disapproval according to what happened previously in the ancient time.”
And Allah Ta’āla Knows Best
Checked and Approved by,
Mufti Ebrahim Desai.
 [Al-Qur`an, 7: 172]
 [Ma`arif al-Qur`an, 4: 85, Maktabah Dar al-Uloom, Karachi]
 [Tafsir at-Tabari, 6: 111-2, Dar al-Fikr; Tafsir In Kathir, 2: 771, Dar al-Fikr]
 [Al-Jami` li Ahkam al-Qur`an, 4: 272, Dar al-Hadith, Cairo]
 [at-Tafsir al-Kabir li al-Imam al-Fakhr ar-Razi, 5: 398, Dar al-Ihya at-Turath, Beirut]
 فقال عمر رضي الله عنه: سمعت رسول الله صلى الله عليه وسلم يسأل عنها، فقال رسول الله صلى الله عليه وسلم:” إن الله تعالى خلق آدم ثم مسح ظهره بيمينه فاستخرج منه ذرية فقال خلقت هؤلاء للجنة وبعمل أهل الجنة يعملون ثم مسح ظهره فاستخرج منه ذرية فقال خلقت
هؤلاء للجنة وبعمل أهل الجنة يعلمون ثم مسح ظهره فاستخرج منه ذرية فقال خلقت هؤلاء للنار وبعمل أهل النار يعملون”. فقال رجل: ففيم العمل؟ قال فقال رسول الله صلى الله عليه وسلم:” إن الله إذا خلق العبد للجنة استعمله بعمل أهل الجنة حتى يموت على عمل من أعمال أهل الجنة فيدخله الجنة وإذا خلق العبد للنار استعمله بعمل أهل النار حتى يموت على عمل من أعمال أهل النار فيدخله الله النار”.
[Tafsir al-Qurtubi, 7: 314-5; Tafsir at-Tabari, 6: 113, Dar al-Fikr; at-Tafsir al-Kabir li al-Imam al-Fakhr ar-Razi, 5: 397-8, Dar al-Ihya at-Turath, Beirut; at-Tafsir al-Mazhari, 3: 99, Dar al-Kutub al-Ilmiyyah; Tafsir Ibn Kathir, 2: 772, Dar al-Fikr; Al-Jami` li Ahkam al-Qur`an, 4: 271-2, Dar al-Hadith, Cairo; Ma`arif al-Qur`an, 4: 85, Maktabah Dar al-Uloom, Karachi]
 [Ma`arif al-Qur`an, 4: 86, Maktabah Dar al-Uloom, Karachi]
 [at-Tafsir al-Kabir li al-Imam al-Fakhr ar-Razi, 5: 398, Dar al-Ihya at-Turath, Beirut; at-Tafsir al-Mazhari, 3: 99, Dar al-Kutub al-Ilmiyyah; Al-Jami` li Ahkam al-Qur`an, 4: 273, Dar al-Hadith]
[Musnad al-Imam Ahmad, 6: 441]
 [Sunan at-Tirmidhi, 3076]
[Ma`arif al-Qur`an, 4: 86, Maktabah Dar al-Uloom, Karachi]
 [Ma`arif al-Qur`an, 4: 88, Maktabah Dar al-Uloom, Karachi]
 Both statements can be found in: [Hashiyat as-Sawi ala Tafsir al-Jalalayn, 2: 174, al-Maktabah al-Asriyyah, Beirut]
 [Sahih al-Bukhari, 3158; Sahih Muslim, 5644]
 [Umdat al-Qari Sharh Sahih al-Bukhari, 12: 437; al-Maktabah at-Tawfiqiyyah, Cairo;
ويحتمل أن يراد الإخبار عن بدء الخلق في حال الغيب على ما جاء أن الأرواح خلقت قبل الأجسام , وكانت تلتقي فتتشاءم , فلما حلت بالأجسام تعارفت بالأمر الأول فصار تعارفها وتناكرها على ما سبق من العهد المتقدم
[Fat`h al-Bari Sharh Sahih al-Bukhari, 6: 415, Dar al-Hadith, Cairo]