An electromagnetic lock creates a magnetic field when energized, causing an electromagnet and armature plate to become attracted to each other strongly enough to keep a door from opening, according to YLI Electronics. In most cases, the armature plate is on the edge of the door, while the electromagnet is wired to the building's power grid in the wall next to the door frame.
When current flows through the electromagnet, it creates a strong magnetic field, attracting the relatively large surface of the armature plate on the door. The magnetic field is strong enough to prevent the door from being forced open, requiring a user to input a security code or present a badge to deactivate the electromagnet and free the door.
Most electromagnetic locks are "fail-safe." This means that when the power fails, the door unlocks. This is so people don't become trapped inside secure facilities in case of a fire or other power-supply disruptions. In "fail-secure" electromagnetic locks, the magnet holds back a spring-loaded or weighted locking mechanism. In this case, the door unlocks only while the power is on, and if the power fails, the door seals. These are commonly used in vaults and other high-security areas, to prevent outsiders from breaking in by simply cutting the power.