I have looked up the word 'immigrant': it says that it refers to people who come to live in a different country. Can I also use this word to refer to people who move from rural areas to the city?
No, immigrants isn't normally used for people who move within the same country from rural to urban areas. But such people are often called [economic] migrants, or more specifically...
The relevant OED definition is...
I interpret the last two words of the definition as meaning immigrants are one kind of migrants (specifically, the kind that move to a different country).
No, it's not really appropriate for that context. The word immigrant formally means, as you said:
Someone who simply moves between locations within the same country relocates rather than immigrates. I'm having trouble finding a good noun to describe someone who specifically moves from the country to the city, however. The process as a whole is called urbanization.