We propose a new formula for the entropy of a dynamical black hole—valid to leading order for perturbations off of a stationary black hole background—in an arbitrary classical diffeomorphism covariant Lagrangian theory of gravity in 𝑛 dimensions. In stationary eras, this formula agrees with the usual Noether charge formula, but in nonstationary eras, we obtain a nontrivial correction term. In particular, in general relativity, our formula for the entropy of a dynamical black hole differs from the standard Bekenstein-Hawking formula 𝐴/4 by a term involving the integral of the expansion of the null generators of the horizon. We show that, to leading perturbative order, our dynamical entropy in general relativity is equal to 1/4 of the area of the apparent horizon. Our formula for entropy in a general theory of gravity is obtained from the requirement that a “local physical process version” of the first law of black hole thermodynamics hold for perturbations of a stationary black hole. It follows immediately that for first order perturbations sourced by external matter that satisfies the null energy condition, our entropy obeys the second law of black hole thermodynamics. For vacuum perturbations, the leading-order change in entropy occurs at second order in perturbation theory, and the second law is obeyed at leading order if and only if the modified canonical energy flux is positive (as is the case in general relativity but presumably would not hold in more general theories of gravity). Our formula for the entropy of a dynamical black hole differs from a formula proposed independently by Dong and by Wall. We obtain the general relationship between their formula and ours. We then consider the generalized second law in semiclassical gravity for first order perturbations of a stationary black hole. We show that the validity of the quantum null energy condition (QNEC) on a Killing horizon is equivalent to the generalized second law using our notion of black hole entropy but using a modified notion of von Neumann entropy for matter. On the other hand, the generalized second law for the Dong-Wall entropy is equivalent to an integrated version of QNEC, using the unmodified von Neumann entropy for the entropy of matter.