That was the grace of Celestial Spirit King... if I remembered it correctly. He 'bestowed' Lucy with that power to protect herself -So that she won't be drown in sorrow of losing her contract with nee-san; tho I don't know about the condition/requirement of usage after the battle ended.
How could Lucy use Aquarius-nee-san magic while she hadn't contracted her again??
Oh Juvia, you silly girl...=w=