Source: Living Happily forever by Swami Shantananda Puri Maharaj
All the thoughts arise mainly from our desires for and attachment to worldly objects, which can all be quelled by the repetition of the mantras. Just as an external sound awakens a man from his dream, the mantras representing various types of sound energies have the capacity to wake us up from our long lasting dream called the waking state. The mantras have to be taken from a living Guru (called deeksha or initiation) whose spiritual power also adds substantially to the power of the mantras. Thus the basic principle of vacating the mind of all thoughts in order to get up from the dream called the waking state holds good in the method of mantras too in the following manner.
Chanting mentally a mantra or the holy name of God is again a single thought. If we think it difficult to remain without any thought, then by reducing it to repetition of a single thought like a mantra or a holy name of God, a day will come when the single thought of the mantra also will vanish and the dreamer alone who is all consciousness and the only reality will remain. This is moksha (liberation).
Please check these: Excerpts from a discourse by our Sri Sri Muralidhara Swamiji