Complex sentence: The prophet established the religion and Imams are to preserve the religion and to lead the people by the divine guidance (Walayah) which they inherithed through the prophet.
Split into simpler sentences: The prophet established the religion and Imams are to preserve the religion and to lead the people. Imams inherited the divine guidance (Walayah) through the prophet.