Some researchers believe that sermon 18 of Nahjul-Blaqah used to be part of sermon 17 and was separated by Seyyid Radhiyy and became an independent one. The contents of the sermon also signify this claim for in sermon 17 the Imam (as) sermons about incompetent judges that corrupt and create chaos in society by their incorrect judgments.
Sermon 18 is also about judges that rely on baseless reasons such as qiyas (analogical reasoning), istihsan (juristic preference) and ra’y (individual reasoning) in their judgments and refer to their verdicts as ‘Allah's (swt) verdict’.
After this the Imam mentions every possibility regarding the difference of opinion amongst Islamic judges and jurists and finally refutes the theory of Taswib (ratification)[i] by denying every possibility using logical reasoning and thorough analysis.
In the end the Imam explains about the Quran and states that the only path to guidance is the one which passes through the Quran. Thus this sermon has nothing to do with the ijtihad of Shia scholars and actually promotes it due to the Quran being one of their major references.
[i] Taswib means for the verdicts of judges and jurisprudents to always be in accordance with Allah's (swt) ruling on an issue, even if their verdicts are contradictory.
A number of researchers believe that sermon 18 of the Nahjul Balaghah was originally part of sermon 17 but was separated and introduced as a independent one by Seyyid Radhiyy (the compiler of the Nahjul-Balaghah). The contents of the sermon are good proof of this claim because sermon 17 talks about incompetent judges that make incorrect judgments by which they corrupt society and put people's lives and possessions at stake.
Sermon 18 is also about judges that rely on illogical reasons such as qiyas (analogical reasoning), istihsan (juristic preference) and ra’y (individual reasoning) in their judgments and present them as Allah's rulings.
The Imam begins his sermon this way:
"At times there a case is presented for judgment and the judge issues his verdict using his own knowledge. Then the same case is presented to another judge and his viewpoint completely contradicts the first one! After that they all meet together with their leader that has assigned them as judges and (even though their votes are contrary to each other) he confirms each and every one of them and considers all of them to have given the right ruling."
It might seem strange that some people would verify contrary votes and believe that they are all Allah's (swt) rulings. But as a matter of fact, a group of Sunnis conceive so due to the limitations they have imposed upon themselves that lead to them accepting such a theory.
Imam Ali (as) rebuts this mentality and says: "They believe this way despite the fact that their God is one, and their prophet is one and their book is one!"
The one God surely has only one ruling regarding an issue, because he is aware of everything precisely and as is. He never makes mistakes, forgets anything, becomes ashamed of anything He has done and learns things not known to Him by the passing of time. Therefore, the difference in opinion mentioned cannot be because of Him.
Considering the fact that their prophet is one and infallible in everything (receiving and announcing Allah's (swt) orders precisely without adding or removing anything), he cannot be the origin of the controversy either. The Quran which contains all of their guidelines to life cannot be the cause either because it has no contradiction within itself and has never been altered and changed as a result of being by Allah (swt). Hence their various judgments essentially arise from the incorrect beliefs they have. In reality, Imam Ali (as) considers believing in various and contradictable votes as going astray and even a kind of polytheism.
In the second part of the sermon Imam Ali (as) thoroughly engages in refuting the idea of taswib (ratification) and mentions a few possibilities:
The first possibility: "Has God almighty ordered them to generate controversy and disagreement....?" This possibility is definitely incorrect; because the one God always calls to unity and compromise.
The second possibility: "Has Allah prohibited them from controversy and they believe they are sinning Allah (swt)?" This possibility is wrong too for they claim that they are obeying Allah (swt).
The third possibility: "Was Islam flawed and what they did was perfect it?" This also isn’t correct since every Muslim knows that Islam is the most complete religion.
The forth probability: "Are these people God's partners in which are capable of legislating rules and laws?" This one isn’t correct either because no Muslim whosoever would even think of Allah (swt) having a partner.
The fifth probability: "Has the prophet neglected delivering Allah's (swt) message, even though He has revealed a complete religion to mankind?" This idea is also incorrect for Muslims would never accuse the prophet (pbuh) of such a thing.
In reality, by mentioning these explanations, the Imam wipes out every single way that would supposedly lead to the thought of taswib, concluding its falsehood. As the sermon goes on, he says the only way to uncover the truth is to refer to the Quran in which everything has been explained in and believes jurisprudence is only possible by seeking help from the holy prophet (pbuh) and the imams (as).
In the end of the sermon Imam Ali (as) describes the Quran and says: "The Quran is beautiful and neat on the outside and profound on the inside, its astonishing points countless, its hidden secrets never ending and the only way for the darkness of misguidance to go away is through the rays of its guidance."
Therefore, Imam Ali (as) prohibits us from believing in taswib and instead encourages us to refer to the Quran in order to reach the correct and precise rulings, and actually this sermon is verifying the ijtihad Shia jurisprudents practice.
It should be mentioned that there are two perspectives regarding the Quran and sunnah in the eyes of jurisprudents:
a) One group conceives that what these two references are not enough for answering every religious question, as a result they move on looking for new references, each choosing something he believes to be reliable. One thinks qiyas is the right way, another believes masaleh morsalah is the right means, while the third picks a completely different solution.
b) On the other hand there is another group that admits that the Quran and sunnah are the main and essential references for Islamic rulings and try their best to understand them but it is natural for contradictions to appear for everybody has a specific comprehension and understanding regarding these references.
What is for sure is that Imam Ali (as) isn't scolding something normal, and that he is addressing other things:
a) Following personal opinions instead of what hadiths say (النص).
b) Neglecting to investigate references properly to find the true answer.
c) Not using the proper methods by which the Quran should be comprehended with.
d) Regardless of the presence of the Ahlul-Bayt that are the real interpreters of the Quran, following others and depriving themselves of their knowledge.
e) Refusing to refer to the Quran and sunnah and instead turning to reasoning based on qiyas and istihsan, etc. None of the above are the reasons for why there is difference of opinion amongst Shia scholars and jurispurdents.
The final point: There is very little contradiction between jurisprudents, because there is no contradiction amongst them whatsoever when it comes to the fundamentals of Islam like, prayer, fasting, etc., and even though there might be differences of opinion regarding other branches of Islam, it is something typical and expected, not deserving any scolding.
 For further information, see: Ayatullah Makarem Shirazi and colleagues, Payame Imam (Explanation of the Nahjul-Balaghah), vol. 1, pg. 608 and on.
 Qiyas in fiqhi terms refers to what manteq (logic) refers to as tamthil (similitude) which is in no way considered reasoning that would bring surety and certainty, the most it can do is cause a conjecture.
 Correct understanding of religious texts must be systematic, and in order for such to take place, one needs to refer to all subjects related to an issue in order to have a correct understanding. On this basis, if one strives to reach Allah's (swt) ruling on an issue by following all the reliable methods and sources and by chances is mistaken in his inference, not only won't he deserve to be scolded, but will merit praise and reward for his struggle to learn the truth.
Our imams (as) have been narrated in hadith sources that the mujtahid who strives and tries to learn Allah's (swt) rulings and reaches the correct conclusion and understands what Allah (swt) has to say there, will be rewarded two blessings (one for his struggle and the other for reaching the right conclusion), and if a mujtahid tries but fails to derive the true ruling, he will be blessed with one blessing (in return for his efforts). Therefore, it can be said that there are two kinds of mistake:
a) In the method used to derive a ruling, which covers all methods not acknowledged by Islam
b) In application (meaning that one uses the right method, but mistakenly applies somewhere incorrectly), which is something natural and normal that takes place for all of those who aren't infallible, this isn't considered something bad, because it is something that takes place unwillingly (the jurist tries his best to apply reliable methods and sources, but is mistaken; it isn't his fault) not willingly.
 On one hand, there are hadiths that contradict each other (that jurists need to choose from and distinguish between those that are flawed and unreliable and those that aren't), and on the other hand, there are also differences in the principles used by scholars to derive rulings, all of this makes it totally natural for there to be differences in the final verdicts they issue.
 For further information on the prerequisites necessary for one to be able to make inferences regarding Islamic law, see:
a) Mabaniye Kalamiye Ejtehad, Ayatullah Hadavi Tehrani.
b) Quran and Ijtihad, Question 66 (of this website).