All perfect praise be to Allaah, The Lord of the Worlds. I testify that there is none worthy of worship except Allaah, and that Muhammad is His slave and Messenger.
The origins of the Ka'bah are lost in antiquity. There are many accounts of its construction, rebuilding and later modifications. Some accounts of its construction are unquestionable while others lack the consensus of the scholars. The undeniable accounts of its origin include the construction of:
(1) Ibraaheem
(2) the Quraysh
(3) Ibn Az-Zubayr
(4) Al-Hajjaaj ibn Yoosuf which was done following an order from 'Abdul-Malik ibn Marwaan
The accounts of the construction of the Ka'bah that lack the consensus of scholars are:
(1) the Angels
(2) Aadam (Adam)
(3) Sheeth ibn Aadam
(4) the giant people who lived in the era after Ibraaheem
(5) the Jurhum tribe
(6) Qusayy ibn Kilaab
(7) 'Abdul-Muttalib
There is disagreement over who first built it as some scholars believe that the Ka'bah was established by Allaah The Almighty for Aadam .
Others think that the Angels first built it followed by Aadam .
A third group think that Sheeth was the first to build it. However, the most correct opinion is that Ibraaheem was the first to build it. This is the preponderant opinion. The evidence for this is the Hadeeth (narration) reported from Ibn 'Abbaas who said, "Had people not performed Hajj to this House, Allaah would have made the heavens fall on the earth and the honor of this (act of Hajj) returns to its (House) first builder, Ibraaheem".
Allaah The Almighty Says (what means): {And (remember) when We showed Ibraaheem (Abraham) the site of the (Sacred) House (the Ka'bah at Makkah) (saying): "Associate not anything (in worship) with Me, [Laa ilaaha ill-Allaah (none has the right to be worshipped but Allaah], …} [Quran 22: 26].
He also Says (what means): {Verily, the first House (of worship) appointed for mankind was that at Bakkah (Makkah), full of blessing, and a guidance for Al-'Aalameen (the mankind and Jinns). In it are manifest signs (for example), the Maqaam (place) of Ibraaheem (Abraham); whosoever enters it, he attains security. …} [Quran 3: 96-97]
Those who support this opinion give also the following verse as another evidence. Allaah The Almighty Says (what means): {And (remember) when Ibraaheem (Abraham) and (his son) Ismaa'eel (Ishmael) were raising the foundations of the House (the Ka'bah at Makkah), (saying), "Our Lord! Accept (this service) from us. Verily! You are the All-Hearer, the All-Knower."} [Quran 2: 127]
In addition, there is no sound evidence from the Prophet that the Ka'bah was built before that. However, some people believe that Aadam was the first to build the Ka'bah. Their evidence is a weak Hadeeth reported by Al-Bayhaqi and which describes how Aadam built the Ka'bah.
Allaah Knows best.