Deepfakes are created using a type of machine learning called generative adversarial networks (GANs). GANs consist of two neural networks that work together to generate new content. The first network, known as the generator, creates the fake content, while the second network, known as the discriminator, evaluates the generated content and tells the generator whether it's realistic or not. Through this process, the generator improves its output, and the discriminator becomes more adept at distinguishing between real and fake content.