Origin 622 to 632 CE
The word carries two quite different meanings and conflating them produces most of the confusion about Islamic religious authority.
In ordinary Sunni usage an imam is the person who leads the prayer. Any adult male Muslim who knows the prayer and recites competently may do it, and the qualification stated in the hadith is knowledge of the Qur'an rather than any office. When two men pray together one leads. A mosque employs a salaried imam who leads the five daily prayers, delivers the Friday sermon and answers questions, and that employment is a job, not an ordination. There is no sacrament for an imam to administer and no rite that requires one: a marriage contract needs the parties, the guardian and witnesses, and a funeral prayer needs a congregation. An imam who is dismissed by the mosque committee is simply a Muslim again, because there was never anything else to remove. Title in Sunni scholarship is also honorific, applied to the founders of the schools of law, Imam Abu Hanifa, Imam Malik, Imam al-Shafii, Imam Ahmad.
In Shia Islam the Imam is something else entirely. He is the divinely designated successor to the Prophet, from the family of Ali and Fatima, sinless, and the authoritative interpreter of revelation. Twelver Shia hold that there were twelve, the last of whom entered occultation in 874 and will return; Ismailis follow a different line and the Nizari branch has a living Imam. Under this doctrine the Imamate is not an office anybody appoints to and not a role a mosque hires for, and the everyday Shia prayer leader is not called by the title without qualification.
To describe an imam as a Muslim priest is wrong in both senses, in the first because there is no priesthood to belong to, in the second because the claim being made is far larger than priesthood.