Seems like I recall Picard having been Lt. Cmdr. when he had to step up in a pinch to command the Stargazer
This was described in the MJ Friedman novels, but not in the actual episodes or movies. In those, Picard's rank at the various milestones of his career was never clarified, and we never even learned when he earned his fourth pip - save for us seeing him wear it during his last days of commanding the Stargazer
, in the "The Battle" and "Violations" flashbacks.
We didn't learn whether Picard immediately got command of the ship after his brief heroics, either. Might be he humbly kept on serving aboard the ship until reaching the four-pip rank and finally qualifying for command.
he got busted back to Captain, which seems a bit harsh in hindsight
The harsher, the better - because this was supposed to be a punishment as much as it was supposed to be a reward. Starfleet would probably have wanted to bust Kirk back to Ensign or Spaceman 3rd Class, but public opinion demanded he be rewarded instead. Going down from Rear Admiral to Captain would sound reasonable, all things considered.
Whether you can command a ship in the TOS era while holding rank lower than Captain... Well, as already discussed, we saw two people in Commander braid (two solid braid) doing CO work: Kirk in "Where No Man" and Ramart in "Charlie X". And Pike wore just Lt braid in "The Cage". And in "Pirates of Orion", the Huron
skipper wore no braid at all while his two underlings were Lieutenants...