"The Messenger of Allah entered the Kabah, and was about to come out, when I thought of something, so I came quickly and I found the Messenger of Allah coming out. I asked Bilal: Did the Messenger of Allah prayed inside the Kabah?' He said: 'Yes, two Rakahs between the two columns.'"
Sunan an-Nasa'i Book 24, Hadith 290