We read in Deuteronomy 13:1-3:
If a prophet or a dreamer of dreams arises among you and gives you a sign or a wonder, and the sign or the wonder comes true, concerning which he spoke to you, saying, “Let us go after other gods (whom you have not known) and let us serve them,” you shall not listen to the words of that prophet or that dreamer of dreams; for the Lord your God is testing you to find out if you love the Lord your God with all your heart and with all your soul (emphasis added).
It seems reasonable to conclude that it wasn’t God who gave that false prophet the supernatural ability to work a sign or wonder–it must have been Satan. Yet God permitted it and used Satan’s temptation as His own test to find out what was in the hearts of His people.
This same principle is also illustrated in Judges 2:21-3:8 when God permitted Israel to be tempted by the surrounding nations in order to determine whether or not they would obey Him. Jesus, too, was led by the Spirit into the wilderness for the purpose of being tempted by the devil (see Matt. 4:1) and thus tested by God. He had to be proven sinless, and the only way to be proven sinless is to be tested by temptation.