This paper proposes a novel nature-inspired swarm-based optimization algorithm called elk herd optimizer (EHO). It is inspired by the breeding process of the elk herd. Elks have two main breeding seasons: rutting and calving. In the rutting season, the elk herd splits into different families of various sizes. This division is based on fighting for dominance between bulls, where the stronger bull can form a family with large numbers of harems. In the calving season, each family breeds new calves from its bull and harems. This inspiration is set in an optimization context where the optimization loop consists of three operators: rutting season, calving season, and selection season. During the selection season, all families are merged, including bulls, harems, and calves. The fittest elk herd will be selected for use in the upcoming rutting and calving seasons. In simple words, EHO divides the population into a set of groups, each with one leader and several followers in the rutting season. The number of followers is determined based on the fitness value of its leader group. Each group will generate new solutions based on its leader and followers in the calving season. The members of all groups including leaders, followers, and new solutions are combined and the fittest population is selected in the selection season. The performance of EHO is assessed using 29 benchmark optimization problems utilized in the CEC-2017 special sessions on real-parameter optimization and four traditional real-world engineering design problems. The comparative results were conducted against ten well-established metaheuristic algorithms and showed that the proposed EHO yielded the best results for almost all the benchmark functions used. Statistical testing using Friedman’s test post-hocked by Holm’s test function confirms the superiority of the proposed EHO when compared to other methods. In a nutshell, EHO is an efficient nature-inspired swarm-based optimization algorithm that can be used to tackle several optimization problems.