When the heart is clean of anything that competes with Allah, something really amazing happens. Everything that the person loves will be through, by, and because of Allah; and that you will be left loving only what Allah loves and not loving what Allah does not love.
Once this happens, obedience is a direct consequence. Because your love is in line with of what Allah wants.
There is a very beautiful dua:
“O Allah, I want that I do not want except what You want.”
That is the heart that’s cleaned of anything competing with the love of Allah.
Getting Nearer to Him
Consider this: Allah says in talking about the nearness of Allah that a slave does not do anything more is nearing to Allah other than the obligations. Those are the things which Allah loves most.
And when the slave continues to do those things and then do the nafl, the extra prayers, the extra fast… that person continues to do those things until something amazing happens! Allah said:
… until I love him.
So how do we get the love of Allah?
We focus on the obligatory first and then he adds nafl, and then Allah loves that servant.
And once that happens, now this is amazing! Allah says:
Then I become his hearing with which he hears, his sights in which he sees, his hands with which he strikes…
In this hadith Allah is describing a state where everything you do is in line with what Allah loves; and it comes naturally because you have gone to a state where you are acting upon your love of Allah.