The gift of discerning spirits, or “distinguishing” spirits, is one of the gifts of the Holy Spirit described in 1 Corinthians 12:4-11.
In some, discerning of spirits operates as a constant rather than flashes of insight, distinguishing between the thoughts and intents of the heart. Like all these gifts, the gift of discerning spirits is given by the Holy Spirit, who disperses these gifts to believers for service in the body of Christ.
Every believer has a spiritual empowerment for a specific service, but there is no room for self-choosing. The Spirit distributes spiritual gifts according to the sovereignty of God and in accordance with His plan to edify the body of Christ. He gives His gifts “just as He determines” (1 Corinthians 12:11).
When it comes to the gift of discerning spirits, every born-again believer has a certain amount of discernment, which increases as they mature in the Spirit. In Hebrews 5:13-14 we read that a believer who has matured beyond using the milk of the Word as a babe in Christ is able to discern both good and evil.
The maturing believer is empowered by the Spirit of God to tell the difference between good and evil, and, beyond that, he can also distinguish between what is good and what is better.