The blaze which had raged since Wednesday at Punta Camarinal near Tarifa in the province of Cadiz amid scorching temperatures was contained at 2:30 pm (1230 GMT), the firefighting service in Andalusia announced on Twitter.
— INFOCA (@Plan_INFOCA) August 2, 2018
Firefighters were still at the scene to fully extinguish the blaze, it added.
The flames threatened, but did not enter, the nearby 19,000-hectare Estrecho natural park, a spokesman for the service said.
The park is home to oak, cork and wild olive trees as well as birdlife, such as white storks, vultures and falcons.
It also takes in Bolonia beach, which is regularly included on lists of Spain's best beaches because of its fine white sand and crystal clear waters.
Wind gusts of up to 55 kilometres (35 miles) per hour had fanned the flames, but firefighters said slower winds on Thursday had helped them gain the upper hand against the blaze.
Aumentan los efectivos para combatir el incendio de Punta Camarinal en Tarifa (Cádiz) (Imágenes cedidas por INFOCA) pic.twitter.com/vNu70USdD7
— Europa Press TV (@europapress_tv) August 1, 2018
Like much of Spain, Cadiz is on high alert for forest fires because of a heatwave pushing temperatures past 40C (104 Fahrenheit).
Spain's meteorological office, Aemet, said the hot spell would stretch from Wednesday to at least Sunday as a mass of hot air moves up from Africa.
In 2008, a wildfire destroyed around 500 hectares (1,200 acres) of land in the Estrecho natural park forced the evacuation of around 1,000 people.
Images showed the devastation left by the fire.
Así ha quedado los pinares entre la playa de Bolonia y Punta Camarinal. Segundo de la semana en la zona. pic.twitter.com/zTXzaw3F1f
— Atanasio PérezBernal (@Aperezbernal) August 2, 2018
Forest fires raged in other parts of Andalusia.