The Rambam (Yesodei HaTorah 9:3) after emphasizes that the Torah that was given to us by Moshe may not be changed or manipulated in anyway, even by another prophet. The rationale is that included in the prophecy of Moshe is that the Torah will be eternally relevant and obligatory, therefore a lower level prophet who would claim otherwise would be attempting to uproot the prophecy of Moshe. The Rambam then goes on to explain the exception, when a prophet can be followed even though he is attempting to undermine a halacha in the Torah. The Rambam then writes a very cryptic sentence:
וכן למדנו מחכמים הראשונים מפי השמועה בכל אם יאמר לך הנביא עבור על דברי תורה כאליהו בהר הכרמל שמע לו וכו' והוא שיהיה הדבר לפי שעה, כגון אליהו בהר הכרמל שהקריב עולה בחוץ וירושלים נבחרת לכך והמקריב בחוץ חייב כרת. ומפני שהוא נביא מצוה לשמוע לו וגם בזה נאמר אליו תשמעון. ואילו שאלו את אליהו ואמרו לו היאך נעקור מ"ש בתורה פן תעלה עולותיך בכל מקום, היה אומר לא נאמר אלא המקריב בחוץ לעולם חייב כרת כמו שצוה משה, אבל אני אקריב היום בחוץ בדבר השם כדי להכחיש נביאי הבעל, ועל הדרך הזאת אם צוו כל הנביאים לעבור לפי שעה מצוה לשמוע להם
The difficulty with the Rambam is that he first stipulates that it must be temporary, then he writes that "since he is a navi there is a mitzvah to listen to him", and then he points out in response to those who may ask how this can be done, that it doesn't technically undermine the Torah since "I am only sacrificing TODAY out of the mikdash by the word of Hashem TO CONTRADICT THE BA'AL". Although the Rambam mentions 3 points: 1. temporary. 2. he was a navi. 3. it was for the purpose of contradicting avoda zara; he doesn't list all 3 as conditions, rather he uses the first 2 as conditions and the third as a response to the challengers. What is the Rambam trying to get at with this very verbose explanation?
The gemara in Sanhedrin seems to contradict the gemara in Yevamos 90b regarding the conditions under which a Navi can undermine the Torah. The gemara in Sanhedrin focuses on the fact that Eliyahu was "muchzak" (established as a tzadik, and honest navi - rashi). But the gemara in Yevamos is willing to expand this power to the Rabbonon in general, and the only limitation that is placed is that it be "למגדר מילתא", to protect the Torah by undermining idolatry. Tosafos struggles with how these 2 gemaras fit with one another. One approach that of Tosafos is that the ability to undermine doesn't come from prophesy, rather it is the מיגדר מילתא necessity that permits the temporary violation of the Torah. This power is given through the rationale thinking of the chachamim who deem something necessary. However, the only way that the idolatry would have been undermined is if they could trust that the miracle fire would descend from heaven, and for this it was necessary for Eliyahu to be "muchzak" as a navi to believe that it would actually occur. According to Tosafos the license to slaughter out of the mikdash was למיגדר מילתא, but this would have only been achieved by the fire descending from heaven which they could only rely on because Eliyahu was an established prophet.
The Rambam clearly has a very different approach. First of all, the Rambam writes that Eliyahu's response of "אני אקריב היום בחוץ בדבר השם", implies that the decision of Eliyahu wasn't motivated by rational thinking, rather by the prophesy he had from Hashem (lechem mishnah points this out). Since the Rambam understands that the power that permitted Eliyahu to make this decision was prophecy, the question returns on how to reconcile the gemara in Sanhedrin with the gemara in Yevamos?
It seems to me that the Rambam understands that the gemara in Sanhedrin establishes why there is a mitzvah to listen when the Navi says to violate. The gemara says that since he is "muchzak", a well established Navi, there is a mitzvah of ואליו תשמעון, which requires everyone to listen to him. This is all assuming the Navi has the authority to make the declaration to violate the Torah. If he has the authority then we must listen because he is an established Navi. But, what gives him the authority? To that the gemara in Yevamos says למגדר מילתא, which is a temporary uprooting of the Torah for an important purpose i.e. undermining avoda zara, gives one the authority to do it. Therefore, the Rambam rules "Because he is a Navi (meaning an established Navi), there is a mitzvah to listen. But then the Rambam wants to explain how the Navi himself has the authority to undermine the Torah. If he is challenged by the cynics who question his ability to make such a ruling, Eliyahu would respond - אני אקריב היום בחוץ, בדבר השם, כדי להכחיש נביאי הבעל. Meaning, his authority is based on 3 criteria: 1. "Today" - only temporary. 2. "By the word of Hashem" - prophecy. 3. "To contradict the prophets of the ba'al" - for the sake of protecting the Torah.
In short, the Rambam holds that the gemara in Yevamos establishes the authority of the Navi to undermine the Torah - למגדר מילתא, but the gemara in Sanhedrin explains why we must listen to him and trust that his decision was predicated on the authority granted to him - מוחזק.