The micro machines were self-replicating nanites created by Ramón Salamander, an evolution of his weather controlling technology.
During his encounter with the Second Doctor, Salamander was hurled into the Time Vortex, (TV: The Enemy of the World) but caught in the TARDIS' backwash, emerged in 1960s London when it did. Quickly realising his situation, Salamander rebuilt his fortune and learnt all he could about the Doctor and the Time Lords, scheming to build a space-time vessel of his own. Aware that this would attract the attention of both UNIT and the regenerated Third Doctor, Salamander sent the micro machines to pose as an invading race of alien robots by way of a distraction.
After they'd been destroyed by UNIT artillery, the machines reconstituted themselves using the asphalt as raw material. When one tried to do the same with the Doctor, he used his sonic screwdriver to disrupt its command signals before imprisoning the rest in a force field.
Bringing the piece back to his lab, the Doctor found Salamander posing as his previous self before the machine attacked Jo Grant and began "colonising" her. After the Doctor had entered Jo's subconscious to speak to the invading intelligence, the robot understood its error in colonising Jo and retreated from her body. Unfortunately for Salamander, he hadn't reckoned for the interference of the Master who, intrigued by a supposed alien race he knew nothing about, had investigated his scheme and discovered its full scope.
When Salamander successfully managed to travel back in time, to the year 1868, he used his micro-machines to travel to the Houses of Parliament and attempted to sell them to the British Empire. When the Doctor arrived, Salamander tried to attack him with the machines only for the Doctor to spread the influence of the ones whom he'd convinced to stand down only for the Master to seize control of them. Before the Master could embark on galactic conquest, the Doctor revealed he'd built a contingency for his old friend's inevitable betrayal and assumed control of the machines before he took them to an empty planet where they could evolve and grow.