This study presents a new natural-based algorithm called the Humboldt squid optimization algorithm (HSOA). HSOA is inspired by Humboldt squids hunting, moving, and mating behavior. The HSOA search procedure involves an attack on fish schools, a fish's escape, a successful attack, an attack of bigger squids on smaller ones, and mating, which is the inspiration for creating an algorithm to address existing issues. In HSOA, half of the best populations are Humboldt squid, and the rest are school fish. Individuals connect with each other and cooperate to achieve the optimal response. HSOA is versatile and applicable to mathematical and engineering problems. Solving eighty-four benchmark function problems (twenty-three classic functions, twenty-nine CEC-BC-2017 with 10, 30, 50, and 100 dimensions, ten CEC-C06 2019, ten CEC2020 with 5, 10, 15, and 20 dimensions, and twelve CEC2022 with 10 and 20 dimensions) and twenty-four engineering problems (six CEC2006 and eighteen CEC2011) shows that our proposed algorithm provides proper and acceptable answers to nine algorithms, including well-known (PSO, DE, WOA), recent (AVOA, RW_GWO, HHO and GBO), and state-of-the-art algorithms (LSHADE and EBOwithCMAR). Friedman's rank from HSOA for one hundred and eight problems was 16.45% and 7.45% lower than LSHADE and EBOwithCMAR. Thus, HSOA has the potential to solve various complex problems in the sciences and engineering fields.