1. Matthew 17:13 (ESV)
  2. Exposition

How did the apostles know that Jesus was referring to John the Baptist as Elijah?

Matthew 17:13 (ESV)

13 Then the disciples understood that he was speaking to them of John the Baptist.

In short

The apostles had grown enough in faith to see that Jesus was speaking about John, even without his saying so expressly. His preaching, recorded in Matthew 11:10, bore fruit. He likely did not mention John by name so that the apostles might draw the conclusion themselves. By God’s grace, they could now see this even before the further direct revelation after the resurrection. The herald mentioned in Malachi 4:5 was not the Elijah whom they had seen during the transfiguration (Matthew 17:3), but John the Baptist. The fact that Matthew 17:13 says that the disciples understood it implies that they had a clear answer to their question reported in Matthew 17:10.

The apostles have now grown in the faith to such an extent that they can understand that Jesus had been speaking about John, even without Jesus having to say so expressly. The preaching of Jesus recorded in Matthew 11:10 bore fruit. Jesus likely did not mention John by name in order that the apostles might draw the conclusion themselves. They now did so By God’s grace, they could now understand this even before the further explicit revelation after the resurrection.1
The forerunner mentioned in Malachi 4:5 was therefore not the Elijah whom they had just seen during the transfiguration (Matthew 17:3), but John the Baptist, whom they presumably had all seen and heard before. The fact that Matthew 17:13 reports that the disciples understood it implies that they had received a satisfactory answer to the question they had posed in Matthew 17:10.2