Imam explains the matter through his theological works as following:
For instance, the acquisition of religious knowledge, is one of the important religious duties and a kind of worship; but a man busy attaining excellence in this field is liable to fall an easy prey to the vice of riya’, which seizes his heart in such a way that he himself is not aware and the same thick curtain of self-love obstructs his vision.
He desires to gain an important position in the eyes of great scholars and men of distinction and honor, by solving an important problem in such a way that no other person has solved it before; he tries to project himself as a person distinguished from others by presenting the subject in a unique way, to make himself the focus of everyone’s attention; with an air of self-assurance, he assumes that if anyone among the scholars and dignitaries eulogizes him in flattering terms, he will be able to receive the applause and praise of the whole gathering.
The poor fellow fails to realize that even if he earns worldly fame and honor among scholars or the elite, he will be disgraced in the eyes of the King of kings, and these actions of his will lead him to Sijjin.
This act of riya’ is also accompanied with some other vices, like the wish for humiliating and insulting others, or injuring the feelings of his brother in faith, or sometimes being rude to a believer; each one of these vices is enough for landing him in hell.
If again your deceptive self falls in the snares of its own guiles and succeeds in convincing you that your aim has been to make known a tenet of Shari’ah and pronouncing the word of truth, which is one of the most meritorious acts of religious devotion, and that you do not aim at demonstrating your spiritual superiority, you ought to interrogate your self by asking that if a friend of yours had solved the same religious issue in a better way and had defeated you in the gathering of those scholars and highly placed persons, even then would you have taken the same position?
If it is so, you were true to your own self. But if your self again is bent upon deceiving others and does not refrain from committing another treachery and contends that the utterance of truth is a meritorious act, and possesses a spiritual reward also, and that it is in your interest to attain an elevated station in the Hereafter, you are advised to ask your self: Suppose if God Almighty accords you the real glory for your defeat in case you gracefully accept it, would you still desire to prevail?
If you see that your self loves to dominate others in academic discussion for gaining publicity among the scholars for your knowledge and scholarship, and the discussion that you undertake is aimed at winning others’ respect and honor, then know that the intellectual discourse, which is the highest form of worship and prayer, is transformed into the sinful act of riya’, which, according to the narration of al-Kafi, will lead you to Sijjin, you are classed as a polytheist, and this act was performed with the motive of gaining respect in the eyes of the people.
This act of yours, according to a tradition, will cause more harm to your faith than the harm done by two wolves that attack a herd of sheep without a shepherd from both sides, Imam further explains.
Therefore, you who are a scholar and responsible for reforming the Ummah and paving the way to the Hereafter, and curing spiritual infirmities, it is necessary for you first to correct yourself and maintain a sound spiritual state, so that you do not fall under the category of the scholars who do not act upon what they profess.
Pray to God Almighty to purify our hearts of the stains of polytheism and hypocrisy, and cleanse the mirror of our hearts of the rust of the love of the world, which is the source of all vices.
O God! Kindly help us and protect us helpless beings, afflicted with the disease of vanity and the lust for power and honor, and guard us in this hazardous journey along the intricacies of the labyrinthine dark path, O the Mightiest and the Most Powerful.
Read more:
Imam Khomeini's recommendations for the seminaries of religious learning