It may come as a surprise to many Shīas, that there are multiple hadīths in the classical Shīa works that speak of thirteen Imāms instead of twelve. Today, Shīa scholars would dismiss these are scribal errors. These reports often state that there will be Twelve Imāms from the descendants of the Prophet – peace be upon him – , meaning that `Alī is excluded from the Twelve.
Evidences for Thirteen Imāms
1- Al-Kulaynī narrated from Moḥammad bin Yaḥyā, from Abdillāh bin Moḥammad Al-Kashshāb, from Ibn Samā`a, from `Alī bin Al-Ḥasan bin Ribāṭ, from Ibn Uḏayna, from Zurārah, that he said: I heard Abā Ja`afar (as) say: “The Twelve Imāms from the household of Moḥammad (peace be upon him and his household) are all spoken to (by angels), from the descendants of the Messenger (peace be upon him and his household) and from the descendants of `Alī, and the Messenger of Allah and `Alī (as) are the fathers.”
Al-Kulaynī narrated this hadīth through the path of Abī `Alī Al-Ash`arī, from Al-Ḥasan bin Ubaydillāh, from Al-Ḥasan bin Mūsā Al-Kashshāb from `Alī bin Samā`a.
The hadīth was also reported by Al-Ṣaffār.
2- Al-Kulaynī narrated from Moḥammad bin Yaḥyā, from Moḥammad bin Al-Ḥusayn, from Ibn Maḥbūb, from Abī Al-Jārūd, from Abī Ja`afar (as), that he said: “I entered upon Fāṭima (as) and in front of her was a tablet with the names of the awsiya’ (successors) from her descendants. I counted twelve with the last being Al-Qā`im (the Mahdī) (as). Three were named Moḥammad and three were named `Alī.
Al-Ṭūsī narrates this hadīth through an alternative chain with the same wording.
3- Al-Kulaynī narrated from Moḥammad bin Yaḥyā, from Moḥammad bin Aḥmad, from Moḥammad bin Al-Ḥusayn, from Abī Sa`īd Al-Uṣfurī, from `Amr bin Thābit, from Abī Al-Jārūd, from Abī Ja`afar (as) that he said: The Messenger of Allah (peace be upon him and his household) said: “Me and twelve of my descendants, and you O’ `Alī, are the stakes and the mountains of the earth. Allah uses us to hold firm the earth and not collapse, and if the Twelve from my descendants disappear, then the earth would collapse immediately.”
4- Al-Kulaynī, with the same chain, from Abī Sa`īd, who narrated it from Abī Ja`afar in a disconnected form, from Abī Ja`afar (as), that the Messenger of Allah (peace be upon him and his household) said: “From my descendants are twelve honorable leaders that are spoken to (by angels), the last of them is the Qā`im (the Mahdi) who shall fill it (the earth) with justice in the way it was filled with tyranny.”
5- Al-Karājiki quotes Aḥmad bin Moḥammad bin Sa`īd, from Al-Qāsim bin Moḥammad bin Ubayd, from Ibn Kallūb, from Al-Ḥusayn bin Zayd bin `Alī, from Ja`afar bin Moḥammad, from his fathers, that `Alī said: The Messenger (peace be upon him and his household) said “…how can a nation with me in it, as well as twelve of my satisfied wise descendants, at its forefront, and the Messiah the son of Mary, in the end, fall to its demise?! Rather, the destruction shall occur to those in between, those who are not from me nor am I from them!”
6- The earliest Shīa book, Kitāb Sulaym bin Qays, included evidence that the Imāms are thirteen. See below.
The reports that indicate that the Imāms were thirteen do not seem to be based upon any ideological basis, for there was no early “Thirteener” Movement. Unlike the reports that indicate that the Imāms are twelve, the reports above, are not ideologically driven. It is very possible that one of these reports was concocted with an arbitrary number and that it went on to spawn multiple hadīths.
Given the fact that the book of Sulaym included the number thirteen, it is safe to say that this number most likely predated the number twelve, since Sulaym was a tabi’ī, who passed away in the first century of Islam.
Correcting the Imāms
It shouldn’t come as much of a surprise that each and every one of the six points provided above has been in a way “corrected”, in order to fit with the Twelver narrative.
I had previously analyzed examples #1 and #5 previously, and I have concluded that these late distortions appear to have occurred at the hands of “Al-Ṣadūq”.
Report #2 was tampered with multiple times in the works of Ibn Bābūyah, where the words “from her descendants” were removed. However, Ibn Bābūyah also quotes it with the same wording as Al-Kāfī in some of his other works, which indicate that these reports were manipulated by someone else.
Narrations #3 and #4 were tampered with as well. Both can be found in the asl of `Abbād Al-`Usfurī with the number “eleven” replacing the number “twelve”. Even though the asl predates Al-Kāfī, the original manuscript was written in 374 AH by Manṣūr bin Al-Ḥasan bin Al-Ḥusayn Al-Ābī, fifty years after Al-Kulaynī. Furthermore, there is absolutely no reason for Al-Kulaynī to sabotage the hadīths of `Abbād, while it is favorable for the copyist to do so. However, one cannot be certain as to whether these distortions occurred at the hands of Al-Ābī, for it may have occurred by an earlier narrator or perhaps a later copyist. Naturally, we can be reassured that Al-Kāfī’s wordings are more representative of what `Abbād had originally written.
Number of Imāms in the Book of Sulaym
Finally we come to the report of Sulaym bin Qays in his book, which according to Ibn Al-Ghaḍa`irī, advocated that the number of Imāms are thirteen. He denounces the book as a forgery due to this as well as other reasons.
Hibatullāh bin Aḥmad bin Moḥammad Al-Kātib, propagated this belief based on the contents of the book of Sulaym. He was the grandson of one of the emissaries of the Mahdī, who authored a work in which he claimed that the Imāms were thirteen, and included Zayd bin `Alī as one of them. He relied on a hadīth that stated that “the Imāms from the descendants of `Alī are twelve,” which could be found in the book of Sulaym. Hibatullāh passed away in the fifth century. Al-Najāshī, who provides us with this biographical information, puts no effort into correcting Hibatullāh’s usage of the report in the book of Sulaym. 
Al-Mufīd is not explicit about the number of Imāms, however, he does state that the book should not be relied upon, apparently due to hidden manipulations. It wouldn’t be surprising if Al-Mufīd held this opinion due to the reasons held by Ibn Al-Ghaḍā`irī.
However, in modern prints of the book of Sulaym today, we find that the number of Imāms is clearly twelve. Moḥammad Bāqir Al-Anṣārī, the editor of the book, quotes 24 instances in which they are numbered as twelve. Is it possible that Ibn Al-Ghaḍā`irī, Hibatullāh Al-Kātib, and by extension Al-Najāshī all overlooked these instances?
It appears as though the case for Thirteen Imāms was one that was lost in time due to both the strength of the Twelver movement, as well as the manipulations in the hadīths. These manipulations would have most likely occurred during the ghaybah period, after the passing away of Al-Ḥasan Al-`Askarī, to support the Twelver ideology that only finally evolved into that form by the middle of the third century.
 Al-Kāfī 1/531
 Al-Kāfī 1/533
 Baṣā`ir Al-Darajāt p. 340
 Al-Kāfī 1/532
 Al-Ghaybah p. 139
 Al-Kāfī 1/534
 Al-Kāfī 1/534
 Al-Istinṣār 7-A
 Distortions of Al-Ṣadūq p. 25, 28
 `Uyūn Akhbār Al-Riḍā 1/52, Kamāl Al-Dīn p. 311, p. 313
 Man Lā Yaḥḍarhu Al-Faqīh 4/180, Al-Khiṣāl p. 478
 Al-Usūl Al-Sittatu `Ashar p. 139-140
 Al-Rijāl p. 63
 Rijāl Al-Najāshī p. 440
 Muṣanafāt Al-Shaykh Al-Mufīd 5/149
 Kitāb Sulaym 1/173-179