By Monica Whitlock
BBC correspondent in Tashkent
Russia and Tajikistan have signed an accord to make legal hundreds of thousands of Tajik migrants in Russia.
Tajikistan relies heavily on Russian economic assistance
The deal was part of a package of measures agreed between Russian President Vladimir Putin and his Tajik counterpart, Emomali Rahmonov.
The issue is of the utmost importance to Tajikistan.
When attackers beat to death a nine-year-old Tajik girl in St Petersburg last winter, the case brought to light the size of the problem.
Between 200,000 and a million migrants have made the long, hard journey, many with no proper papers, to find work in bazaars and on building sites.
Most make it - their remittances may now be about equal to the national budget, supporting huge families and even whole villages.
But life can be extremely harsh, and the Tajiks are constantly harassed by the authorities.
Police in the Urals this week arrested more than 100 Tajik men in a funeral cortege.
They had been going to bury the body of a friend who had died, they said, because no doctor would treat him.
Under the new accord, all migrants will have legal status and medical insurance - both existing workers and those to come.
The migrants have chosen Russia because it was the colonial power in Central Asia and many speak at least some Russian.
Very few intend to remain, most returning after they have made enough to start a business at home.
No intergovernmental agreement will solve all their problems, many of which are rooted in racist attitudes.
But the document signed may make life much easier after the parliaments ratify the accord early next year.