In ancient times, Romans exploited the gold mines in what is now Transylvania extensively, building access roads and forts to protect them, like Abrud. The region developed a strong infrastructure and economy, based on agriculture, cattle farming and mining. Colonists from Thracia, Moesia, Macedonia, Gaul, Syria, and other Roman provinces were brought in to settle the land, developing cities like Apulum (now Alba Iulia) and Napoca (now Cluj Napoca) into municipiums and colonias.
The Dacians rebelled frequently, the biggest rebellion occurring after the death of emperor Trajan. Sarmatians and Burs were allowed to settle inside Dacia Trajana after repeated clashes with the Roman administration. During the 3rd century increasing pressure from the free Dacians (Carpians) and Visigoths forced the Romans to abandon exposed Dacia Trajana.
In 271, the Roman emperor Aurelian abandoned Dacia Trajana and reorganised a new Dacia Aureliana inside former Moesia Superior. The abandonment of Dacia Trajana by the Romans is mentioned by Eutropius in his Breviarium Liber Nonus.
The province of Dacia, which Trajan had formed beyond the Danube, he gave up, despairing, after all Illyricum and Moesia had been depopulated, of being able to retain it. The Roman citizens, removed from the town and lands of Dacia, he settled in the interior of Moesia, calling that Dacia which now divides the two Moesiae, and which is on the right hand of the Danube as it runs to the sea, whereas Dacia was previously on the left.
The first wave of the Great Migrations, (300 to 500) brought the influence of migratory tribes, especially the Germanic tribes. The Visigoths established a kingdom north of Danube and Transyilvania between 270-380. The region was known by Romans as Guthiuda and includes the region between Alutus (Olt) and Ister (Danube) too. It is unclear whether they used the term Kaukaland (land of the mountains) for Transylvania proper or the whole Carpathians. The (Vizi)Goths were unable to preserve the region's Roman era infrastructures. The goldmines of Transylvania were ruined and unused during the Early Middle Age. Ulfilas had carried (around 340) Homoean Arianism to the Goths living in Guthiuda with such success that the Visigoths and other Germanic tribes became staunch Arians. When the Goths entered the Roman Empire (around 380) and founded successor-kingdoms, most had been Arian Christians.
In 380 a new power reached Transylvania, the Huns. They drow back every Germanic people from the Carpathian Basin except the Gepids. The Alans, Vandals, Quads left the region toward the Roman Empire. The Huns extended their rule over Transylvania after 420. After the disintegration of Attila's empire, Transylvania was inhabited by the remnants of various Hunnic, and a Germanic tribe, the Gepids. The Transyilvanain Gepids had a semiindependent status inside the Kingdom of Gepids, but this relative autonomy came to an end in the late 6th century.
The rule of Gepids was crushed by a Lombards and Eurasian Avars attack in year 567. In fact the Gepids were exterminated from the region. We know only about slight Gepid remnants (cemeteries) in the Banat region after 600. In Transyilvania we have no traces which indicate a Gepids continuity after 567. By 568, the Avars under the capable leadership of their Kagan, Bayan, established in the Carpathian Basin an empire that lasted for 250 years. During this 250 years the Slavs were allowed to settle inside Transylvania and they started to clear the Carpathian's virgin forests. The Avars meet their demise with the rise of Charlemagne's Frankish empire. After a fierce seven-year war and civil war between the Kagan and Yugurrus which lasted from 796-803, the Avars were defeated. The Transylvanian Avars were, subjugated by the Bulgars under Khan Krum at the beginning of the 9th century and Transylvania, along with eastern Pannonia, was incorporated into the First Bulgarian Empire.
In 862, Moravian Prince Ratislav rebelled against his lord, hired Magyar troops to help him, and with their aid he won his independence. This is the first time when Magyar expedition troops entered the Carpathians Basin. After a devastating Bulgar and Pecheneg attack the Magyar tribes crossed the Carpathians and occupied the entire basin without significant resistance. According to the prime Gesta Ungarorum from the 11th century they entered Transylvania first, where Prince Almos was killed: "Almus in patria Erdelw occisus est, non enim potuit in Pannoniam introire". According to some archeological findings near Turda (Golds of Prince Berthold of Bavaria) Transylvanian Magyars also participated in several raids against the West, Italy, or the Balkans. Although the defeat in the Battle of Lech in 955 stopped the Magyar raids against western Europe, the raids on the Balkan Peninsula continued for one more decade.
The history of Transylvania during the early Middle Ages is difficult to ascertain due to the scarcity of reliable written or archeological evidence. There are two major conflicting theories concerning whether or not the Romanized Dacian population (one of the ancestors of the Romanians) continued to live in Transylvania after the withdrawal of the Romans, and therefore whether or not the Romanians were present in Transylvania at the time of the Great Migrations, particularly at the time of the Magyar migration; see: Origin of Romanians. These conflicting hypotheses are often used to back competing nationalistic claims by Hungarian and Romanian chauvinists.