Artwork from Pokémon's official Sun and Moon website
Z-Moves are a special type of move introduced in Generation VII. They are performed when a Pokémon and its Trainer's wishes are unified, and they both bring forth their full power with a specific pose.
Although these moves are very powerful and don't take up any of a Pokémon's four move slots, they can only be unleashed once per battle in Pokémon Sun and Pokémon Moon. In the second set of titles, Pokémon Ultra Sun and Pokémon Ultra Moon, if a trainer's friendship with their Rotom Dex is high enough (by touching the outside of the Rotom Dex when it appears upset), it may use a special power of its own during battle to allow the trainer to use one additional Z-Move over the remainder of the encounter.
In order for a Pokémon to use a Z-Move, it must be holding the corresponding Z-Crystal, and its Trainer must possess a Z-Ring as well as the same Z-Crystal.
There are two different kinds of Z-Moves: 18 of them correspond to a specific type, and then several others are specific to a certain Pokémon. They all draw their power from a move the Pokémon knows, using PP of that move in the process.
Each type has a corresponding Z-Move that any Pokémon can use, as long as it knows a move of the same type. For example, any Pokémon that knows an Electric-type move can use the Electric-type Z-Move, Gigavolt Havoc. The base power for these moves, and whether they are physical or special, depends on whatever move the Pokémon knows that is the same type.
In the case of Gigavolt Havoc, if the Pokémon knows Nuzzle (20 power), Gigavolt Havoc will be physical and have 100 power. If the Pokémon instead knows Thunderbolt (90 power), Gigavolt Havoc will be special and have 175 power. If the Pokémon knows multiple moves of that type, you'll be able to choose which to draw power from.
Other Z-Moves are specific to certain Pokémon, or a related group of Pokémon. They have specific required moves that the Pokémon must know in order to perform them.