Muslims have unanimously agreed that temporary marriage was legislated by the Prophet (peace be upon him and his holy progeny). The second caliph stopped people from doing it during his rule at a famous incident. Since it was legislated by the Prophet, it remains lawful and valid. And this is what the followers of the Ahlul-bait (peace be upon him) and a group of the companions of the prophets (peace be upon him) believe.