Sa'id bin Abi Sa'id al-Maqburi heard Sayyiduna Abu Hurayrah (may Allah be pleased with him) say that the Messenger of Allah (peace and blessings be upon him) sent a cavalry detachment towards Najd, and they brought back a man from the tribe of Banu Hanifah called Thumamah bin Uthal, the chief of Yamamah. The Companions tied him to one of the pillars of the mosque. In this hadith it is stated that the Messenger of Allah (peace and blessings be upon him) said: "Release Thumamah." So he went to a date-palm near the mosque, took a ritual bath, then entered the mosque and said: 'Ashhadu an la ilaha illallah wa anna Muhammadan rasulullah' (I bear witness that there is no god worthy of worship except Allah, and that Muhammad (peace and blessings be upon him) is the Messenger of Allah). And he mentioned the rest of the hadith.
(b) In Sahih al-Bukhari it is stated that the bath came before the testimony of faith. It is also possible that he accepted Islam in the presence of the Prophet (peace and blessings be upon him), then took a ritual bath, entered the mosque and declared the testimony openly; this reconciles the two narrations.
Hadith Referenceالسنن الكبرى للبيهقي / كتاب الطهارة / 806