Malachi 4:5 gives the prophecy that Elijah will come before "the great and terrible day of the Lord." John the Baptist in responding to the direct question regarding whether or not he was Elijah answered that he was not (John 1:21, 26-27). But yet Jesus (Matt. 11:14) stated that he was Elijah. Is this a contradiction? Did John not realize who he was? Is this a testimony to the possibility of reincarnation? The answer to all three questions is "No!" The ultimate answer, therefore, can be found in Luke 1:17 in which Zechariah is given the prophecy that John will be one who has "the spirit and power" of Eljah.
The Bible would never teach reincarnation (Heb. 9:27). And so it is important to recognize that the "spirit" of Elijah illustrates that John was to be the fulfillment of the Malachi prophecy, because his authority and testimony of judgment for sins was reminiscent of Elijah's work while he was alive. Elijah sought to return the people back to God (1 Kings 18) and John had the same ministry because he was a forerunner to the Messiah. The Messiah we know to be Jesus of Nazareth.