A new population-based metaheuristic called Zebrafish Optimization Algorithm (ZFO) is proposed to find the global optimum solution using foraging behaviour of zebrafish larvae (Danio rerio). In ZFO, an exploration and exploitation trade-off is realized by simulation of exploratory dispersion, collaborative shoaling and directional searching. The movement strategy incorporates a stagnation-avoiding reinitialization mechanism, ensuring that diversity is maintained and premature convergence is avoided. To demonstrate the efficiency of ZFO, 23 benchmark functions including unimodal, multimodal and fixed dimension multimodal functions are tested and their optimal solutions are searched. Results obtained by ZFO are compared with existing metaheuristic algorithms, namely Cuttlefish Optimization, Jellyfish Search, Pufferfish Optimizer and Krill Herd algorithm. The Friedman rank test and Wilcoxon signed-rank test show that ZFO yields better-quality solutions than the compared algorithms in terms of convergence speed and robustness. The novel characteristic of ZFO is that it combines biologically inspired zebrafish dynamics and adaptive diversification strategy to enhance the capability of global search.