(covers information from several alternate timelines)
This page contains information regarding Star Trek: Discovery, and thus may contain spoilers.
A demotion was when an individual within a military or other hierarchical structure was given a reduction of rank or position by a commanding officer. A demotion was by definition the opposite of a promotion.
After his less-than-impressive dealings with the Nausicaans in 2151, First Officer Matthew Ryan of the Earth Cargo Service freighter ECS Fortunate was demoted to able crewman in order to have to earn back Captain Keene's trust. (ENT: "Fortunate Son")
The same year, Commander Trip Tucker threatened Lieutenant Malcolm Reed that he was going to "bust your ass back to crewman second class for insubordination," though Reed countered, "Be my guest. I could use a little less responsibility." (ENT: "Shuttlepod One")
The next year, Captain Jonathan Archer gave Reed the same warning, heeding that, "If I were the kind of captain you think I should be, I'd bust your ass back to crewman," after Reed had tried to disconnect his EV suit's air supply. (ENT: "Minefield")
In 2259 of the alternate reality, James T. Kirk was demoted from captain to the rank of commander after he had violated the Prime Directive on the planet Nibiru. Later, Kirk was assigned as first officer of the USS Enterprise under Captain Christopher Pike. (Star Trek Into Darkness)
In 2269, Janice Lester (posing as James T. Kirk) and Leonard McCoy discussed the service record of Arthur Coleman, who had lost his post as chief medical officer. Lester told McCoy that promotions and demotions were subject to political maneuvering, but McCoy stated this wasn't the case either at Starfleet Headquarters or the Surgeon General's office. (TOS: "Turnabout Intruder")
In 2286, Rear Admiral Kirk was demoted to captain by the Federation Council for disobeying a direct order from the Commander, Starfleet, Morrow. (Star Trek IV: The Voyage Home; Star Trek VI: The Undiscovered Country)
Following an incident on Garon II in the 2360s, Ro Laren was demoted to ensign. Several years later, in 2368, Captain Jean-Luc Picard thought she would have made lieutenant commander by that time, if not for her actions. (TNG: "The Next Phase")
In 2372, Dukat was demoted from chief military advisor of the Detapa Council to a position commanding the Cardassian military freighter Groumall. Dukat later thought about demoting his rival Gul Marratt and assigning him to the Cardassian embassy on Breen, when it seemed Dukat could return to power. (DS9: "Return to Grace")
The same year, Seven of Nine reassigned Harry Kim to chamber maintenance and gave him the new designation Two of Ten, essentially demoting him. When Kim protested, Seven claimed this was a useful Starfleet protocol she had adapted. (VOY: "The Omega Directive")
The following year, Phlox mistakenly informed his superiors that The Doctor was in command of the USS Voyager. Fearing demotion, he asked the Voyager to maintain that illusion to a number of Hierarchy Assault-class vessels. (VOY: "Tinker Tenor Doctor Spy")
Commander Michael Burnham was stripped of all rank for the charge of mutiny (DIS: "Battle at the Binary Stars"). Her rank was later restored (DIS: "Will You Take My Hand?"). She was promoted to First Officer (DIS: "Die Trying"), but was stripped of this role for disobeying a direct order , although her rank was not reduced. (DIS: "Scavengers", "Unification III")
In an alternate timeline 2404, Captain Harry Kim worried that Starfleet Command would demote him back to ensign once they learned about him and Kathryn Janeway attempting to alter the timeline. (VOY: "Endgame")
In other cases, a reduction in rank or responsibility could be given to an officer as a non-punitive formality, or as a political move.
In the early 2270s, Rear Admiral James T. Kirk replaced Captain Will Decker as the commanding officer of the USS Enterprise. This resulted in Kirk receiving a temporary grade reduction from rear admiral to captain. Kirk, in turn, gave Decker a temporary grade reduction to commander and had him stay on as the ship's executive officer. (Star Trek: The Motion Picture)
Commander William T. Riker was granted a field commission to captain of the USS Enterprise-D following the capture of Captain Jean-Luc Picard by the Borg in 2366. After the return of Picard to the Enterprise, Riker resumed his role as first officer and returned to his previous rank of commander. (TNG: "The Best of Both Worlds", "The Best of Both Worlds, Part II", "Family")
Late in the Dominion War in 2375, General Martok was honored by Chancellor Gowron with the Star of Kahless, who described the general as "the most famous warrior in the Empire." Following the ceremony, Gowron took over Martok's command with the preface that "I can't ask you to carry this weight forever. It's time for me to take a more active role in this war," before announcing that "I'm assuming direct command of our forces." Gowron sugar-coated the demotion by telling Martok to "Be happy. You're a warrior again. No more meetings, no more reports to file. You'll be out there, savoring the heat of battle. I envy you." In reality, according to Worf, this was a political move made by the chancellor because he wished to be the savior of the Empire himself. (DS9: "When It Rains...")
In 2399, retired Starfleet admiral Jean-Luc Picard made a request to Fleet admiral Kirsten Clancy that she temporarily reinstate him for one mission. In his appeal, he said that he would "be content with being demoted to Captain." This did not come to pass, however, as the Flag officer angrily denied Picard's request. (PIC: "Maps and Legends")