In the Star Trek: The Next Generation episode "Encounter at Farpoint", Q showed up dressed as a Starfleet officer.
What was his rank?
Going by timestamp 1:22:56 on the Netflix version you can see both Q and Picard standing side-by-side and their ranks are identical. I was going to say captain off the top of my head, but I'm pretty sure that confirms it.
Edit: see Wikis' screen cap for the actual frame.