In the 21st century, with the advancement of science, humans were able to create industrial humanoid robots to help with different tasks, and they coexist peacefully. However, in the first Mega Man game, the scientist Dr. Albert W. Wily plans to take over the world, and the foremost authority on robotics, Dr. Thomas Light, modifies the helper robot Mega/Rock into the super robot Mega Man (Rockman) to stop Wily, starting a series of battles between the two scientists and their creations.
History

Not taking the defeat lightly, Dr. Wily created eight of his own humanoid robots in Mega Man 2. These eight were designed solely to fight and take down Mega Man. He sent them back to pick up where he left off in his previous attempt. Mega Man once again heads out to save the day.
After defeating Dr. Wily for the second time, the evil doctor vowed to mend his ways and make up for all his past mistakes by offering his assistance to Dr. Light once again. Together they built eight more robot masters and even began working on a giant peace-keeping robot called Gamma. Gamma was being constructed to keep the events of the past from ever happening again.
In order to construct Gamma, special crystals were needed. Dr. Light and Dr. Wily built special mining robots in Mega Man 3 to gather these crystal for them. During the mining process however some of the robots went berserk and drove out all of the humans. Mega Man was then sent to retrieve these special crystals for them, accompanied by his robotic dog Rush. It turns out that in the end Wily was behind the whole plan and was stealing the crystals for himself. As soon as he had stolen all of the crystals he activated Gamma and tried to use it to take over the world and defeat Mega Man. In the end Mega Man destroyed Gamma and had Wily in his grasp. The fighting had weakened the fortress they were in began to collapse and Mega Man was trapped under the rubble. Wily made his escape and the base still crumbled. Proto Man rushed in and saved his brother's life. However, Wily was believed to have died in the collapse of the base.
By Mega Man 4, Dr. Mikhael Cossack, a Russian Robotologist, was pressured by Dr. Wily into creating Robot Masters to attack the planet by holding his daughter, Kalinka, hostage. However, Wily was eventually found out by Mega Man, and Proto Man then retrieved Kalinka and returned her to Cossack, thus allowing him to not have to follow Wily's orders anymore, although Wily escaped after being defeated by Mega Man.
An entity resembling Proto Man was then sighted attacking various places on Earth, although it was later revealed to be Dark Man, a Robot created by Dr. Wily to frame Proto Man as revenge for the latter's betrayal of him. He eventually escaped again.
After going underground, Dr. Wily eventually assumed a change in identity as the millionaire Mr. X, as well as developing the X Foundation and hosting a tournament of Robot Masters. However, he then reveals his intentions of trying to conquer Earth. After briefly fighting against Mega Man and being beaten by him, X then unveils his true identity to Mega Man. After being defeated a second time, he attempts to escape, but is instead stopped by Mega Man, and this time placed in jail.
Unfortunately, Dr. Wily had anticipated the possibility of Mega Man also arresting him, and arranged for several robots to awaken and devastate the city he is being held at should he have failed to have escaped. He also had Bass, a robot he accidentally created alongside the energy source Bassnium, fake allegiance to Dr. Light, and eventually also get himself wounded so he could steal a prototype Super Adapter. Wily narrowly managed to escape from Mega Man.
Effects
As a result of the fighting, Dr. Light began to see a need for robots to be able to decide between right and wrong for themselves, as well as better virus countermeasures due to the results of Evil Energy and Roboenza. Combining both these features lead to his final creation, the first robot with free will, X. However, the years had caught up with Light. Knowing he would not live to ensure X was ready and with no one to carry on his work, he had X sealed in a capsule for 30 years of ethical testing until the day he was ready. A century later, X's discovery by Dr. Cain would give birth to the Reploid race.
Dr. Wily also owed his final creations to the conflicts. His discovery of Bassnium allowed him to further his knowledge and create his final robot, Zero, and a virus with which he could live on and wreck havoc, the Maverick Virus. The only thing that prevented him from unleashing both upon the world immediately was the flaw in Zero's mental coding that made him too dangerously violent for Wily to control, forcing him to seal Zero away. Zero's release a century later would lead to the spreading of the virus and the start of the Maverick Wars.