It took an entire team of Avengers to take down Thanos in Avengers: Endgame, but several powerful MCU villains could have stopped his path to genocide far sooner. While there are certainly candidates emerging, such as Kang the Conqueror or Gorr the God Butcher, it's quite possible that no MCU bad guy will ever outclass Thanos. The Mad Titan's quest for and ensuing use of the Infinity Gauntlet powered so much of the MCU's third phase, and some doubt if the stakes and scale of Endgame can ever be matched.
With all six Infinity Stones at his disposal, it's arguable no one could have conclusively defeated Thanos, as adding the power of those stones to his own power level effectively made him a god among mortals. It is telling that Avengers: Infinity War's fateful snap.
Before Thanos gathered the Infinity Stones, the MCU had played host to multiple powerful villains that could have–at least in theory–overcome Thanos and prevented half of the universe from being turned to dust. Whether or not they would care enough to do so is another question, though. That aside, here's a look at villains who ed the MCU before Infinity War and possessed the necessary power to knock Thanos down a peg.
Dormammu
As laid out directly by Wong, Dormammu is a being of infinite power and endless hunger, seeking to forcibly absorb every universe into his Dark Dimension home. Doctor Strange was famously able to use the Time Stone to trap Dormammu in a loop that frustrates the monster into leaving Earth, but a pre-Infinity War Thanos would not have possessed that artifact. As strong as even normal Thanos was, Dormammu would likely have squashed him like a bug if they ever went head to head. Thanos' saving grace in this scenario would be that there's no reason for the two to have crossed paths in the normal course of events. Perhaps if Strange had known Thanos was coming, he would have added another caveat to his bargain with Dormammu.
Ego
Both introduced and killed off in Ego was Peter Quill's living planet father with a human-like extension. More importantly, Ego was a Celestial, making him a much older and far more powerful figure than Thanos. Guardians 2 made it pretty clear that without his own son being in the mix, Ego likely would've been unbeatable, and it's almost impossible to imagine a pre-Infinity Gauntlet-wielding Thanos being able to defeat him. In fact, a fully powered up Thanos still likely would have faced severe difficulty against a fully powered up Ego. Unfortunately, Ego–fittingly given his name–was far too selfish to consider stepping in even if he had seen Thanos' rise and resulting genocide coming.
Surtur
While the towering fire beast Surtur was often played for laughs during his one and only MCU appearance in Thor: Ragnarok, in the end, it was certainly no laughing matter. So strong was Surtur that once he was fully unleashed and powered up by The Eternal Flame artifact, he was basically unstoppable. His possible use against Thanos could be made clear by how Thor and Loki use him in Ragnarok, as the giant monster was employed to defeat their extremely powerful sister Hela. While this act also doomed Asgard as a planet, it became clear there was no other option available. If Surtur could destroy an entire planet, he could have destroyed Thanos.
Hela
Hela, the Goddess of Death herself, was also arguably powerful enough to beat Thanos, if only because a fully powered up and Stormbreaker-equipped Thor nearly managed to do so near the end of Infinity War. Since Hela was clearly much more powerful than Thor, and the only way the son of Odin was able to defeat her was by sacrificing his entire planet to Surtur, there's definitely an argument to be made that Hela could have not only beaten but outright wiped the floor with a Thanos that didn't have all six Infinity Stones. However, one downside would be that Hela and Thanos may well have gotten along and chosen to snap away half the universe together.
Ultron
Ultron, the Tony Stark and Bruce Banner A.I. creation that went rogue and threatened to destroy humanity, may not seem like the most obvious candidate to defeat Thanos. However, the MCU actually explicitly endorsed the idea in Disney+'s animated If neither had any Infinity Stones available, Thanos would most likely win a fight against Ultron fairly easily, but since Ultron was "born" using the Mind Stone, there would have been no instance where the two could have met in the standard MCU where Ultron didn't possess it.
Lorelei
Lorelei, a villain from the Thanos' non-standard Titan physiology would have prevented him from being susceptible to Lorelei's abilities. If not, he would have had to bend the knee to her just like any other man. As with Hela, though, there's no guarantee she would not just use him to further her own MCU ends.