Yes, a landlord can generally keep some or all of your security deposit if you break your lease early, but only to cover actual financial losses the landlord suffers because of the early move-out, not as an automatic penalty. Breaking a lease is a breach of contract, and the deposit can be applied toward unpaid rent, cleaning, damage, or costs tied to re-renting the unit.
Most leases require tenants to pay rent through the end of the lease term or until the landlord re-rents the unit, whichever comes first. If you leave early and stop paying rent, the landlord can typically deduct the unpaid rent owed for the remaining lease period from your deposit. However, nearly every state requires landlords to make a "reasonable effort" to re-rent the apartment rather than letting it sit empty and billing the former tenant for months of rent they didn't actually lose. This is called the duty to mitigate damages. If the landlord quickly finds a new tenant, your liability—and what they can deduct from your deposit—shrinks accordingly.
Beyond unpaid rent, a landlord can also deduct for genuine damage beyond normal wear and tear, unpaid utility bills you were responsible for, and sometimes a lease-break or re-letting fee if your lease specifically spells one out. What they generally cannot do is keep the entire deposit simply as punishment for leaving early if the actual costs were much lower, or charge you for cosmetic wear that happens with ordinary living.
Some leases include an early termination clause that lets you break the lease by paying a flat fee (often equal to one or two months' rent) or by giving extra notice. If your lease has this option and you follow its terms, the landlord's ability to also come after your deposit for lost rent is usually limited to whatever the clause specifies.
After you move out, the landlord still owes you the same deposit procedures required in any move-out: an itemized list of deductions and the remaining balance, returned within the state's required timeframe (commonly 14 to 30 days, depending on the state). If a landlord keeps the full deposit without any explanation or itemization, that is a red flag regardless of whether you broke the lease early.
If you're planning to leave early, the smartest move is to read your lease's early termination and subletting clauses before you go, give written notice as soon as possible, leave the unit clean and undamaged, and ask the landlord in writing what they intend to deduct and why. Keep copies of all communication and photos of the unit's condition when you leave. If the landlord withholds an amount that seems disconnected from actual losses, or refuses to document re-renting efforts, you can dispute the deductions in small claims court, where many of these cases get resolved. A local tenant rights organization or an attorney can help if the amount in dispute is significant or the landlord is uncooperative.