I have looked up the word 'immigrant': the definition 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...
Rural migrants are attracted by the possibilities that cities can offer, but often settle in shanty towns and experience extreme poverty. (source: Wikipedia article on urbanisation).
The relevant OED definition is...
migrant: A person who moves permanently to live in a new country, town, etc., esp. to look for work, or to take up a post, etc.; an immigrant. (italics mine)
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:
a person who comes to a country to take up permanent residence
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.