After the defilement of the Temple by the Antichrist, the Messiah will defeat him in battle during the Great Day of the Lord.
Then the Messiah will cleanse and sanctify the Third Temple.
When He establishes the Kingdom He will build the fourth Temple north of Jerusalem as described in Zechariah 6:12 and Ezekiel chapters 40 and 48.