"We will continue to clean the virus from all state bodies because this virus has spread. Unfortunately like a cancer, this virus has enveloped the state.
"We knew this and told all relevant authorities," he warned thousands of mourners at the Fatih mosque in Istanbul.
During a passionate speech, the president paid tribute to the "martyrs" of democracy, insisting that the people were stronger.
"They may have tanks but we have our faith. We will not leave the squares ... But we will continue defiantly.
Also Read
More than 100 coup plotters were also killed, the military said.
Despite fears in the West and the United States that Erdogan would wreak revenge, he said: "Don't forget this, we are not vengeful."
The remarks appeared to be in response to US President Barack Obama's call for all parties to "act within the rule of law" and for leaders to "avoid actions that would lead to further violence or instability".