The early occupation of its site dates back to pre-Roman fort.
At the time of the Roman invasion and occupation of the Iberian Peninsula, the town was designated under the name Budua. During its occupation by the Visigoths, they called it Niguela. From the eighth century Umuyyad Muslims had the town fortified.
At the time of the Reconquista of the Iberian Peninsula, reconquest of the village and its surrounding land was finally achieved in 1230, by Castilian and Leonese forces. Years later, on 28 May 1255, the Wise men of Badajoz county donated Ouguela and elsewhere to the Bishop of Badajoz.
By the Treaty of Alcañices on 12 September 1297, the domains of Ouguela and its castle transferred to the Crown of Portugal. The following year, King Dinis (1279–1325) in Lisbon on 5 January 1298, aimed at increasing Ouguela's settlement and defense, and granted the town a charter with many privileges, with a focus on its defense.
During the reign of Ferdinand I of Portugal, construction began on the new city wall, works that continued under the reign of John I of Portugal (1385-1433). The latter, also with the aim of establishing and defending the city, granted it the privilege of a fortified township (7 December 1420).
During the War for the Restoration of Portuguese independence, the advisers to John IV (1640–1656) determined that there was a need to modernize its defenses, which included fortified lines designed by the French architect Nicolau de Langres.
It was during this period that a legendary event took place. In 1644 a Spanish force of 1,500 cavalry and 1,000 infantery coming from Badajoz and under the command of Carlo Andrea Caracciolo marquis of Torrecuso, invaded the Alentejo. A Portuguese traitor, João Rodrigues de Oliveira, offered the Spanish to conquer the city with a ruse. But some residents became aware of his plans and organized a hasty defense.