The duration of an earthquake is primarily determined by the magnitude of the earthquake, the distance from the epicenter, the type of fault slip (e.g., strike-slip, reverse, normal), and the geological properties of the rocks in the area. Additionally, the depth of the earthquake and the amount of stress released during the event can also influence its duration.