As well as the Navy rank, it is also a rank in the Metropolitan police; a Commander is immediately superior to a Superintendent.
Curiously the rank does not exist in other UK forces; The Met seem to need more high ranks, presumably because of their size.
P.D. James' fictional detective Adam Dalgleish is a police Commander. It's an unusually high rank for a detective in a novel to have because very senior policemen don't see a lot of crime.
Of course, the Naval version has a much more famous fictional holder; James Bond is a Commander.