A civilian helicopter carrying the Turks, an Afghan and two others was forced to land in bad weather in eastern Afghanistan in April.
The group was abducted by insurgents in a remote part of Logar province where the Taliban have a strong presence.
Mr Erdogan said the men were freed with the help of Turkish intelligence.
The Turkish construction workers were flying to Khost, south-east of the capital Kabul, when their Russian Mi-8 helicopter was forced to land in the restive district of Azra on 21 April.
Azra is close to the Pakistani border and local officials say that while there are some Afghan government forces there, the Taliban and other insurgents control the area.
Two pilots, from Russian and Kyrgyzstan, and an Afghan translator were also reported to have been kidnapped in the incident.
The Taliban told the BBC last month that the captives were in good health and that no decisions had been made about their fate.
Mr Erdogan told a rally in Istanbul on Sunday: “Eight Turkish engineers were kidnapped recently in Afghanistan when their helicopter crash landed. Thanks to the efforts of MIT [Turkish intelligence], four of them were handed over to us and are safe.”
Tribal chiefs also helped to secure their release, AFP news agency reports.
Turkey has around 1,800 soldiers serving with Nato forces in Afghanistan, but their mission is confined to patrols and Ankara has long had a close relationship with Kabul.
Several Turkish engineers have been kidnapped in Afghanistan in recent years, with some held for up to two years.
Numerous Western, Pakistani and Afghan hostages are being held in Afghanistan including US Army Sergeant Bowe Bergdahl, 25, who has been a prisoner for nearly four years