In this study, we numerically investigate heat transfer enhancement in a partially thermally active rectangular enclosure. The enclosure is filled with a ternary hybrid nanofluid (water, Carbon Nanotube, Al2O3, and Graphene). It is subjected to a magnetic field and uniform internal heat generation. The study also investigates the effect of magnetic field strength and direction on the natural convection flow, which arises from density fluctuations caused by partial heating of the left vertical wall. To solve the dimensionless governing equations, the finite element approach is employed. The parameters studied in detail include Rayleigh number (Ra), Hartmann number (Ha), nanoparticle volume fraction (ϕ), and heat generation coefficient (λ). The findings are presented graphically for the range of the parameters as follows: 103≤Ra ≤106, 0≤Ha≤20, 0.01≤ϕ≤0.05, and 0≤λ≤15. It is noted that these parameters have an impact on heat transfer enhancement, flow patterns, and temperature fields. The results show that the average Nusselt number (Nu¯) increases with an increasing value of ϕ. Moreover, it has been noted that Nu¯ decreases as the value of Ha increases, and the impact becomes more obvious at higher Ra values. Finally, the influence of the heat generation coefficient on the heat transfer rate inside an enclosure is examined.