his tenure is for life
how he is selected? khobregan.
Indeed Khomeiny was a real grand ayatollah very popular and well followed. he was the main person of the revolution. it doesn't mean he became less and less popular for many reasons but we cnnot compare him to Khamenei.
To become leader, you have to be grand ayatollah and given your rosaleh ... so you need to pass the "exam" of Qom. It is religious matter here. But indeed Khamenei was never Grand Ayatollah. He said that Khomeiny said him (without proof) that he wanted Khamenei to be the leader so Khamenei was cheating everyone in the khobregan with the help of Rafsandjani.
Then Khobregan elects the leader but since he came to the khobregan as the choosen one nobody could say anything against.