In a moment of sudden clarity, Nehemiah exposes a political trap disguised as divine revelation. He comes to the firm realization that the man standing before him, Shemaiah, is merely posing as a prophet, and that God certainly did not send him [שטיינזלץ, מלבי״ם].
The primary approach among commentators explains that this understanding stems from a logical analysis of the supposed prophecy. Shemaiah had advised Nehemiah to hide inside the Sanctuary to save his life from assassins. While a person might assume that the need to save a life overrides religious prohibitions, Nehemiah understands that God would never send a prophecy commanding a person to sin out of a fear of death [רש״י, מצודת דוד]. God possesses countless ways to bring salvation and does not need to force a person into committing a transgression in order to rescue Him [מצודת דוד].
Shemaiah completely fabricated the message [אבן עזרא], falsely presenting his own advice as the word of God [רש״י]. His actual goal was to strike fear into Nehemiah, pushing him to sin by entering the restricted holy space. This would effectively destroy Nehemiah's reputation and provide his enemies with the perfect excuse to publicly disgrace him for violating the Torah [רלב״ג].
Another perspective suggests that Nehemiah identified the deception by noticing a glaring internal contradiction. Previously, Shemaiah had prophesied that Nehemiah would rule over Israel. Nehemiah realizes that if God had truly promised him leadership, there would be no reason to hide in fear. A true prophet would have encouraged him to remain fearless, confident that God's word would be fulfilled. The sharp contrast between the promise of leadership and the advice to hide proved that both of Shemaiah's prophecies were entirely false [מלבי״ם].
Ultimately, Nehemiah concludes that his bitter enemies were behind the plot. Either Tobiah or Sanballat had secretly paid the false prophet [אבן עזרא, מצודת ציון, מצודת דוד]. They hired Shemaiah to use these fabricated prophecies as a weapon of fear, hoping to break Nehemiah's resolve and halt the rebuilding of Jerusalem's walls [רש״י, רלב״ג, שטיינזלץ].