A man has allegedly driven his car into the gates of a Queensland mosque while shouting offensive words to worshippers inside.

Police said the 23-year-old Brown Plains man was stopped on Buckley Road at Stockleigh about 2.20pm on Saturday for a side drug test, which tested positive.

Police have charged a man after he allegedly rammed his car into the front gates of a mosque.

The driver was issued with a 24-hour driver's licence suspension notice and a notice to appear for drug-driving.

It will be further alleged once the man was released from police custody, he returned to his car on Buckley Road and drove to the Baitul Masroor Mosque on Neville Road.