BERLIN (Reuters) - An EU agreement with Britain on relations after Brexit could serve as a model for ties with other countries that want to be as close as possible to the bloc but are not yet ready to join, such as Ukraine and Turkey, Germany’s foreign minister said.

Anti Brexit protesters demonstrate outside the Houses of Parliament in London, Britain December 11, 2017. REUTERS/Peter Nicholls

Britain secured the go-ahead from Brussels to start talks on its future relationship with the EU earlier this month, with London saying it aspires to a closer relationship as a former member than that of any other third country.

In an interview with the Funke newspaper group published on Tuesday, German Foreign Minister Sigmar Gabriel said such a deal could offer a solution to the puzzle of how the bloc of 27 can manage its ties with two other large non-members.

“I can’t imagine Turkey or Ukraine becoming EU members in the next few years,” he said. “If we get a smart agreement with Britain regulating relations with Europe after Brexit, that could be a model for other countries - Ukraine and also Turkey.”

Turkey, a candidate for EU membership for decades, already has a customs union with the EU which allows the trade of most goods without tariffs.

One possibility would be to offer Ankara a “new, closer form of the customs union”, Gabriel said, although he also said such a project would have to wait for changes in Turkey’s political environment.

Thousands of people, including German citizens, have been detained in Turkey as part of a government crackdown since a failed coup in 2016.

An agreement between the EU and Ukraine on a “deep and comprehensive free trade area” formally came into force in September, aimed at allowing free trade of goods, services and capital, and visa-free travel for people for short stays.

Ukraine’s desire for closer ties with the EU was one of the driving forces behind a popular revolt that toppled a pro-Russian president in 2014, leading Moscow to seize Ukraine’s Crimea peninsula and back pro-Russian separatists in a still-unresolved conflict in the east of the country.

Gabriel’s Social Democratic Party (SPD) is preparing for talks with Chancellor Angela Merkel’s conservatives on governing together for another four years.