A Demotion is a punitive reduction in a person's rank. A member of the United Federation of Planets Starfleet can be reduced in rank for serious violation of laws or regulations.
Following the disastrous first contact between the Federation and the Talin people in 2269, both Spock and Nyota Uhura were reduced to the rank of ensign. Spock chose to resign from the fleet instead of remaining in at that reduced rank. When it was discovered that an alien force had been interfering in Talin society, Spock and the remainder of the Enterprise crew were restored to their former ranks and positions. (TOS novel: Prime Directive)
In 2286, James T. Kirk was reduced from the rank of admiral to captain as punishment for his actions in disobeying the Starfleet Commander in rescuing Captain Spock from the Genesis Planet. However the council also ordered that Kirk be returned to starship command. (TOS movie: Star Trek IV: The Voyage Home)
Following an attempted coup by Admiral James Leyton, his chief supporter Captain Erika Benteen was court martialled for attacking the USS Defiant and for supporting Leyton's attempted coup. Benteen was acquitted of most of the serious charges made against her, however she was demoted back to the rank of Commander for one year. Benteen later regained her captain's rank and commanded the USS Appalachia during the fight against the Borg at the Battle of Sector 001. (ST video game: Starship Creator; TNG movie: First Contact)
Lieutenant Tom Paris was demoted to the rank of Ensign in 2375 for disobeying the orders of Captain Kathryn Janeway and sentenced to thirty days in the brig. (VOY episode: "Thirty Days") At the end of 2376, Paris was reinstated as a lieutenant. (VOY episode: "Unimatrix Zero")
After the destruction of the USS Equinox, Captain Kathryn Janeway stripped the five surviving Equinox officers of their commissions. (VOY novelization: Equinox)