Ahaziah had fallen through the lattice in his upper chamber in Samaria, and lay injured; so he sent messengers, telling them, "Go, inquire of Baal-zebub, the god of Ekron, whether I shall recover from this injury." But the angel of the Lord said to Elijah the Tishbite, "Get up, go to meet the messengers of the king of Samaria, and say to them, 'Is it because there is no God in Israel that you are going to inquire of Baal-zebub, the god of Ekron?'" Now therefore thus says the Lord, "You shall not leave the bed to which you have gone, but you shall surely die.' So Elijah went. (NRSV 1:2-4)
And Ahaziah fell down through a lattice in his upper chamber that was in Samaria, and was sick: and he sent messengers, and said unto them, Go, enquire of Baalzebub the god of Ekron whether I shall recover of this disease. But the angel of the Lord said to Elijah the Tishbite, Arise, go up to meet the messengers of the king of Samaria, and say unto them, Is it not because there is not a God in Israel, that ye go to enquire of Baalzebub the god of Ekron? Now therefore thus saith the Lord, Thou shalt not come down from that bed on which thou art gone up, but shalt surely die. And Elijah departed. (KJV 1:2-4)
God, using Elijah to communicate his message, cuts off Ahaziah's attempt to discover his fate from Baal-zebub and delivers his death warrant. This is meant to demonstrate how much greater God is than Baal-zebub, because he knows to deliver the message without even being asked.