Umm...Did Ultron defeat The Avengers? Well, they did defeat him with Vision on their side (and thats from the brutally incorrect movie. The comics version of Ultron has been defeated several times by the Avengers without any hep from Vision.) , I suppose. And, Braniac is always defeated by Superman (unless we're talking about the Justice League Animated Series, where the Flash actually ripped Brainiac into pieces, effectively removing him from the symbiotic bonding with Lex Luthor) , just that he is able to leave a copy of himself somewhere to be reactivated later, just like Apocalypse or Mr.Sinister in the X-Men/Marvel Universe who uses clones.
I don't think that AI will win over human kind. Afterall, we do have T-800 aka Arnold Schwarzenegger to save mankind by travelling back in time or even our future champion John Connor who will defeat any AI super-intelligenece if they achieve world domination in the near future. Or, else we'll call Dr.Who. He deals with sci-fi stuff like these on a daily basis without breaking a sweat.
Now, speaking outside of fiction;
Hardware wise the amount of processing and data storage resources required would be great (Mind Uploading). Software wise we still need to manually teach the AI learning machines with correct and incorrect data sets of inputs as to what is correct and incorrect and a lot of human supervision is required. Our robotics is not that advanced yet. Though we've got exosuits like Iron Man armors but they have issues of energy source and weight to performance ratio. In order to deal with the weight to preformance ratio the researchers are now moving onto soft-exosuits without the metal-works. [Link , Link , Link] Now, we've got advanced drones and missiles etc which can be hacked into as they're all computer controlled, like SKYNET did in Terminator 2: Judgement Day. But, nuclear and missile systems are made quasi-remote in their operational. That is there are two people assigned with every missile silo (lauch base), who have to manually put in a key or key card at the same time with their own code authorization known only to them to actually initiate the launch. The president or the general's orders, desipte looking directly enabled via computers or such devices, is just one more key to a three key or multiple key system.
AI cannot take over Human Kind because AI at their core are logical systems they cannot handle any paradoxes or philosophical mysteries and even an existentialist crisis (Existentialism). A very famous puzzle game called Portal, by Valve, delt with AI's as main atagonists. In the second sequel to the game Portal 2 , the previous AI antagonist is replaced by another AI antagonist which happened to be a stupid AI (i.e. designed to be stupid), which would not even understand a paradoxical question like - "This statement is false." Which should've looped and crashed the AI. While humans are able to coexist with uncertainities and paradoxes without pulling their hair out.
So, it all depends on how "human" the AI is designed to be. Showing loss of memory, autonomy of choosing a problem or fact while ignoring others (We call these "Biases" in psychology and is useful for making localized and general decisions). The AI which plays a pivotal role in the TV series "Person of Interest" (I fanatically recommend watching it. Its a good show.), was taught compassion and turned out to be in favor of humans, while a new antago