It seems that you have either sprained your muscle or injured one of your discs in the spine. In such case, you should not continue gym at least for few days. You can take rest at home and hot fomentation using hot water/ electrical belt. Once pain gets better, start with simple exercises like walking. Any ointment will also be useful but avoid vigorous massage
Health Tips
if you start getting leg symptoms (pain, numbness, weakness) then you should consult a spine surgeon.