A delegation from Babylonia put forth a query to the prophet Zechariah, asking whether the fast of the Ninth of Av was still in effect, now that the Second Temple had been built. In response, Zechariah revealed a message from Above: after the arrival of the Mashiach, all fasts will be turned into holidays:
“So says haShem Tz’vaot: The fast of the fourth month [the seventeenth of Tammuz], the fast of the fifth month [the ninth of Av], the fast of the seventh month [the third of Tishrei], and the fast of the tenth month [the tenth of Teves] will be to the House of Judah for rejoicing, happiness, and festivals.” (Zechariah, 8:19)
This prophecy was made in the period when the Second Beit ha-Mikdash was being built in Jerusalem after the Babylonian exile. By that time, the new Beit ha-Mikdash building had already been erected, but the interior work continued and was completed only two years later. Therefore, the question concerned the need to observe the fast, associated with the destruction of the Beit ha-Mikdash.
The answer of the prophet Zechariah received the status of a Jewish law and is included in halachah (Rambam, “Tur”, “Shulchan Aruch”).
You can find a more detailed description of these events in the book of Zechariah (chapters 7 and 8).