A retractable leash with automatic locking and unlocking function including a housing, a spool with a cord wound therearound, a braking means, a cord opening, a stopping means and a biasing means. A second portion of the stopping means abuts against the cord in such a way that tensioning of the cord by an external force actuates the stopping means to overcome biasing force of the biasing means to rotate to the locking position, and untensioning of the cord by the external force returns the stopping means from the locking position to the unlocking position. The present invention automatically locks the leash when the dog rushes, thus improving safety of the leash.