In the Rambam’s Code we find a clear ruling pertaining to the order of events through Moshiach:1

“He will rebuild the Beis Hamikdash in its place and then will gather the ingathering of exiles.”

It is known that the Rambam shows significance and meaning even in the order of his rulings, as is also seen in the beginning of this Chapter:2

“The King Moshiach will arise and will fully restore the Kingdom of David to its original esteemed sovereignty; then he will rebuild the Beis Hamikdash and will gather the remnants of Jews in exile.”

No posek (Codifier) disagrees with this order and ruling. And the Halachic principle is3 that wherever the Commentaries on Rambam do not disagree with him, it is proof that they agree with his ruling. In our case, this refers to the renowned Codifiers — Raavad, Kesef Mishneh, Radvaz, etc. (who show no disagreement with this ruling re: the order of Moshiach’s activities).

Practical, legal rulings are found and authenticated only in the works of Poskim, and not in Midrashic or Talmudic sources. And Rambam is the classical authoritative Codifier, especially in the area of Moshiach.

As such, Moshiach will usher in the final end of exile and then will come the beginning of redemption, followed by the true and complete redemption. After this, Moshiach will bring the ingathering of the exiles to our homeland, Israel.