BRUSSELS (Reuters) - The European Union will let Ukrainians and Georgians visit the bloc freely after diplomats and lawmakers agreed on Thursday on an emergency brake to suspend visa waivers, ending an EU dispute holding this up.

People hold up Georgian (L) and Ukrainian flags during celebrations for the signing of an association agreement with the European Union in Tbilisi, Georgia, June 27, 2014. REUTERS/David Mdzinarishvili/File Photo

Wary of immigration after an uncontrolled influx of more than a million refugees and migrants from the Middle East and Africa last year, EU has made relaxing travel rules for any new countries conditional on first agreeing the snap-back mechanism.

But internal EU talks on it stalled for many weeks, delaying agreement on visa waivers for the two former Soviet republics and raising criticism that the bloc was reneging on pledges to help them as they try to move away from Moscow’s orbit.

The agreement paved the way for visa waivers for first Georgia and then Ukraine. Both are still at least a few weeks away but should not be derailed now.

“Almost there. Visa suspension mechanism dispute over. Now the final stretch towards visa free travel for Ukraine and Georgia,” said European Council President Donald Tusk.

The prospect of easier travel to Europe has been used by the pro-Western governments in Kiev and Tbilisi to win popular backing for painful EU-sponsored reforms.

Ukrainian President Petro Poroshenko hailed “encouraging news from Brussels” and Georgian Foreign Minister Mikheil Janelidze said: “Georgia is Europe and it will become more and more tangible for our people.”

Georgia, with only 3.7 million citizens, is an easier case for the EU but has been held hostage by the greater hesitation over Ukraine, which has 45 million people, is geographically closer and is stuck in a conflict with Russia.

Under Thursday’s deal, the European Commission or a majority of EU states will be able to swiftly suspend any country’s visa exemption for nine months if its citizens suddenly start making many more asylum requests, stay in the bloc for longer than allowed or cause a “substantial increase in the risk to public policy or internal security.”

If the problem persists, the bloc would be able to extend the suspension for another 18 months in a more complex procedure that would also give the European Parliament a say.

Related talks on a visa waiver for Turkey, a mostly Muslim country of 79 million people, have stalled now as ties between the bloc and Ankara soured in the aftermath of a botched military coup in the latter in July.