In the Star Trek: The Next Generation episode "Encounter at Farpoint", Q showed up dressed as a Starfleet officer.
What was his rank?
Science Fiction & Fantasy Stack Exchange is a question and answer site for science fiction and fantasy enthusiasts. It only takes a minute to sign up.Sign up to join this community
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.