"The good news is that the wildfire that started in La Junquera was brought under control today," said Felip Puig, interior minister of the north-eastern Catalonia region where the fire broke out on Sunday near the French border.
"We are going to continue working still for two or three more days but at the moment the perimetre of the fire has been stabalized," he told AFP in the town of Figueres.
The fire, which officials believe was likely caused by a discarded cigarette butt, has ravaged over 14,000 hectares (35,000 acres), devouring tall trees and leaving charred earth and flocks of dead sheep in its wake.
About 1,500 people including emergency and military personnel and local volunteers battled the blaze on Tuesday, backed by 25 French and Spanish aircraft.
Water-bombing planes were grounded Monday because of high winds.
Four people have been killed since the fire began.
One Frenchman and his 15-year-old daughter died after jumping off a cliff and another Frenchman died in hospital from burns after his car was engulfed in flames.
A 75-year-old Spanish man died of a heart attack as he watched his house go up in flames.
Six people remained in hospital on Tuesday, including a nine-year-old boy who was in intensive care, the regional health department said.
Emergency services ordered thousands of area towns to stay indoors with their windows and doors shut because of the threat from the smoke and flames.
Hundreds of people, including tourists a campsite, were evacuated Monday and spent the night in emergency shelters set up in the region, mostly in the town of Figueres, a few kilometres south of the border.
Mark Van Persie, a 48-year-old Dutchman who drove with his family from the Netherlands in their caravan to holiday in Spain, said he was given 10 minutes to pack a few things and leave a campsite in Albanya.
"It was a little scary because we knew that there is only one road and since the wind had changed we saw the smoke coming closer," he said at a gym in Figueres where he and other evacuees were eating breakfast.
"Our caravan is still in the camping place and we don't know when we will be able to go get it. If there is still a caravan when we get there and it hasn't burned."
Sylvain Fouchier, a 35-year-old Frenchman who also fled the camp along with other Belgian, Dutch, French, German and Spanish tourists, said some people were not able to reach the emergency shelters.
"Some people gathered their belongings and tried to leave, but they came back because the roads were closed," said Fouchier, who was on holiday with his wife and three children.
At Capmany, located some 20 kilometres south of the French border, the flames totally destroyed another camp site on Sunday.
"It was my business. We lost everything. Our whole life is there," said Mercedes Gonzalez, the owner of the "les Pedres" campsite as she pointed to a charred pile of junk which is all that remained of its 70 bungalows.
Spain is at higher risk of forest fires than ever this summer after suffering its driest winter in 70 years.
The country's biggest fire so far this year ravaged 50,000 hectares in the eastern region of Valencia this month.