a device that turns DC into AC is called a power inverter. You have one of these in most electric cars. My Prius, for example, has a large battery, which is DC like most batteries, and it's powered by a 3-phase AC motor in addition to the ICE. The Prius uses an array of high voltage, low loss transistors called IGBTs (Insulated Gate Bipolar Transistors) to generate AC from the DC of the battery.
Typical modern inverters are solid-state, transistor based devices. But there have been electromechanical inverters as well. You can make an electromechanical inverter by driving a DC motor to an AC generator, for instance. A square-wave inverter (see below) can be made using a switch controlled by an electromagnet.
An ideal AC power supply is based on a sine wave. But that's a more complex thing to generate, so some inverters take short cuts. Sometimes that's ok, other times it's not, depending on the purpose of the inverter. I added a 600W inverter to my Prius, which I use to power things in the house during blackouts, or while car camping. This inverter generates a true sine wave. That's certainly possible, but more expensive, and not always necessary.
The simplest kind of inverter is callled a square-wave inverter. It simply switches the DC power off and on, creating a square wave output. Simple devices like incandescent lights and motors often work fine when driven from square-wave inverters.
In-between these two are modified-sine-wave inverters. These devices will create a stair-step effect, to more closely model the sine wave using DC switching.