Police are questioning a man who allegedly armed himself with a gun and pulled over a driver in Brisbane, pretending he was an undercover officer.

A man is in custody over allegations he pulled over a car in Brisbane and impersonated a police officer.

A 29-year-old man was stopped by a white ute flashing its headlights on Turbo Drive, Woolloongabba, in Brisbane’s inner south on Thursday night.

The male ute driver approached the other man’s vehicle and showed him a gun, allegedly claiming to be an undercover officer.

The driver was detained for more than an hour before he was told he could leave. He was not injured during the incident.

A man, also 29, was being questioned at the Upper Mount Gravatt police station over the incident on Friday afternoon.

Police have urged motorists who suspect an unmarked car pulling them over is not a police vehicle to contact police or dial triple-zero.

They should also pull over in a safe place, keep doors and windows locked and request to see police ID.