KUWAIT, July 6 (Reuters) - Police dispersed hundreds of protesters in Kuwait late on Sunday as they tried to march from the Grand Mosque to the main court complex to demand the release of prominent opposition politician Musallam al-Barrak.

After warning the chanting protesters that they had failed to obtain a licence for the march and that blocking the road would be illegal, the police fired smoke bombs to break up the gathering, a Reuters witness said.

Kuwait said on Friday it would take all necessary measures against "any signs of disturbance and violence" after police scattered demonstrators the government said had thrown stones, burned car tyres and blocked roads the previous night.

Al-Barrak has been detained for questioning over allegations that he insulted the judiciary. A court hearing for the former lawmaker has been set for Monday.

OPEC producer Kuwait, a U.S. ally, allows more political freedom than other Gulf Arab states. It has a lively press and an elected parliament, but has also banned public gatherings of more than 20 people without a permit.

Unrest flared in 2012 after the ruling emir, Sheikh Sabah al-Ahmed al-Sabah, changed the electoral law before a parliamentary election in December that year.

Barrak and other opposition groups said the move was intended to deny them a majority, and they boycotted the poll.

Barrak, who draws support from some of Kuwait's powerful tribes, was sentenced to jail for insulting the emir in 2013. His arrest and conviction triggered a series of street protests. He was later acquitted. (Reporting by Ahmed Hagagy and Mahmoud Harby; Writing by Maha El Dahan; Editing by Mark Trevelyan)

Our Standards: The Thomson Reuters Trust Principles.