For Sunnis, the term imam has a variety of uses, none of them ‘mystical’, but more in the etymological sense of ‘standing in front’, which is to say it is a general term for one who leads the daily prayers and or who is knowledgeable about doctrine.
For Shiism, the term Imam is used in a special sense for the true spiritual successors of the Prophet and implies certain initiatic and prophetic qualifications. Thus, Ali was the fourth caliph but the first Shiite Imam.
To be more specific, in Shiism the title of Imam carries an esoteric or mystical significance: the Imam participates to some degree in the office of the Prophet and is therefore inerrant (ma’sum) and protected from sin by God. He possesses a perfect knowledge of the Sharia and the Tariqah—the Law and the Way, and by virtue of his investiture he carries the power of initiation (walayah). We could, with certain reservations, say that his role is similar to that of the pope in Catholicism, and is distinct from the Sunni view in the same way that a Protestant ‘prayer leader’ or church pastor is distinct from a priest of Bishop, the difference between the two always hinging on the presence or absence of an initiatic investiture.
This is why it is sometimes said that Shiism presents itself as the esoteric side of the Sunni-Shia division. This would seem to contain some truth since the Shiite Imams are also the spiritual authorities for the Sufis, and almost every Sufi order traces its initiatic chain through the first eight Imams and back to Ali himself, who is the representative par excellence of Islamic esoterism.