During the 3 years following the emergence of the COVID-19 pandemic, the African continent, like other regions of the world, was substantially impacted by COVID-19. In Morocco, the COVID-19 pandemic has been marked by the emergence and spread of several SARS-CoV-2 variants, leading to a substantial increase in the incidence of infections and deaths. Nevertheless, the comprehensive understanding of the genetic diversity, evolution, and epidemiology of several viral lineages remained limited in Morocco. This study sought to deepen the understanding of the genomic epidemiology of SARS-CoV-2 through a retrospective analysis. The main objective of this study was to analyse the genetic diversity of SARS-CoV-2 and identify distinct lineages, as well as assess their evolution during the pandemic in Morocco, using genomic epidemiology approaches. Furthermore, several key mutations in the functional proteins across different viral lineages were highlighted along with an analysis of the genetic relationships amongst these strains to better understand their evolutionary pathways. A total of 2274 genomic sequences of SARS-CoV-2 isolated in Morocco during the period of 2020 to 2023, were extracted from the GISAID EpiCoV database and subjected to analysis. Lineages and clades were classified according to the nomenclature of GISAID, Nextstrain, and Pangolin. The study was conducted and reported in accordance with STROBE (Strengthening the Reporting of Observational Studies in Epidemiology) guidelines. An exhaustive analysis of 2274 genomic sequences led to the identification of 157 PANGO lineages, including notable lineages such as B.1, B.1.1, B.1.528, and B.1.177, as well as variants such as B.1.1.7, B.1.621, B.1.525, B.1.351, B.1.617.1, B.1.617.2, and its notable sublineages AY.33, AY.72, AY.112, AY.121 that evolved over time before being supplanted by Omicron in December 2021. Among the 2274 sequences analysed, Omicron and its subvariants had a prevalence of 59.5%. The most predominant clades were 21K, 21L, and 22B, which are respectively related phylogenetically to BA.1, BA.2, and BA.5. In June 2022, Morocco rapidly observed a recrudescence of cases of infection, with the emergence and concurrent coexistence of subvariants from clade 22B such as BA.5.2.20, BA.5, BA.5.1, BA.5.2.1, and BF.5, supplanting the subvariants BA.1 (clade display 21K) and BA.2 (clade display 21L), which became marginal. However, XBB (clade 22F) and its progeny such XBB.1.5(23A), XBB.1.16(23B), CH.1.1(23C), XBB.1.9(23D), XBB.2.3(23E), EG.5.1(23F), and XBB.1.5.70(23G) have evolved sporadically. Furthermore, several notable mutations, such as H69del/V70del, G142D, K417N, T478K, E484K, E484A, L452R, F486P, N501Y, Q613H, D614G, and P681H/R, have been identified. Some of these SARS-CoV-2 mutations are known to be involved in increasing transmissibility, virulence, and antibody escape. This study has identified several distinct lineages and mutations involved in the genetic diversity of Moroccan isolates, as well as the analysis of their evolutionary trends. These findings provide a robust basis for better understanding the distinct mutations and their roles in the variation of transmissibility, pathogenicity, and antigenicity (immune evasion/reinfection). Furthermore, the noteworthy number of distinct lineages identified in Morocco highlights the importance of maintaining continuous surveillance of COVID-19. Moreover, expanding vaccination coverage would also help protect patients against more severe clinical disease.