Ban has vowed to replace 200 Afghan electoral officials in the run-off poll
Afghan President Hamid Karzai has agreed to hold a run-off to the fraud-hit presidential poll.
The move has been welcomed by Western leaders, including UN Secretary General Ban Ki-moon.
Below is the transcript of an interview he gave to BBC UN correspondent Barbara Plett in New York.
Q: You said the UN had learnt painful and valuable lessons during the elections. What were they?
First of all, this was the first Afghan-led election, and we expected that this should be a transparent and democratic one. Unfortunately, there was widespread fraud. That was quite a painful lesson.
So we realised that it was quite difficult for a young democracy to stand on its own, even with strong international assistance, particularly by the UN.
That's what we should not repeat in the coming second elections, scheduled for 7 November.
Q: The UN spent millions of dollars helping to organise what turned out to be massively fraudulent elections, so shouldn't there be some accountability for the UN as well?
Now if we can see Afghanistan, a young democracy, developing into a much more mature democracy, I think millions and millions of dollars would not be a big issue.
We have tried our best to make everything accountable and transparent, that's why I'm very pleased that President Karzai has agreed to go for a second ballot, which will make the next government of Afghanistan much more legitimate and credible... [and better able] to work together with the international community.
The UN will be able to convene an international conference as soon as this election is over, to support the next Afghan government.
Q: There is a credibility issue for the UN, because of this serious internal division about how to deal with the allegation of fraud. You ended up firing the man whose warnings turned out to be accurate in terms of the extent of the fraud.
I do not agree that [former deputy head of Unama, the UN mission in Kabul] Peter Galbraith's position was the right one.
Everybody's position was right - I made it quite clear in my report to the UN Security Council that there was fraud
Q: You mentioned the fraud, but you didn't go into the extent of it. He's the one who blew the lid on it.
The question of all this controversy was not the scope of fraudulence, and it was not because somebody tried to hide something.
On the contrary, we have made it clear to the Afghan government, we made it clear to the Security Council that there was fraud we wanted to rectify.
I dismissed [Mr Galbraith] for the best interest of Unama's integrity and chain of command
We really wanted to provide a full opportunity to all the Afghan people so that they could cast their free vote to elect their next leader.
We did not want to close or reduce the number of polling stations just to prevent possible fraud - that was the main difference of my position and Unama's position from Mr Peter Galbraith, I'm making that quite clear.
Q: It is the view of some diplomats that the UN has been weakened because of the very public row over how to deal with the election fraud. Do you share that view?
No, I don't think so, that's why I wanted to preserve the integrity of Unama and decided to dismiss [Mr Galbraith].
After that, [Unama chief] Kai Eide has been continuously holding discussions with President Karzai and other international major players.
And I've been talking with President Karzai as well as many world leaders. That is where we have seen President Karzai to agree to stand for the second ballot, which is a wise decision.
Q: What can the UN do to make sure the same mistakes don't happen again in the second round?
We will take all necessary measures, administrative and security.
We will coordinate closely with the Isaf [Nato force] and Afghan national forces to ensure there is security under which the Afghan [people] can express their will without any intimidation or threat.
Secondly, administratively, we will try to replace all the officials who have been implicated in not following the guidelines or who have been complicit in fraudulent procedures.
There are 380 electoral districts throughout Afghanistan, and we will try to replace more than 200 officials who have been implicated or who have not been following correct guidelines to make this election transparent and credible one.
We will also try to visit all the polling stations to make sure that no such fraud can happen, and we will try not to open polling stations where during the first election there weren't any polling elections.
Q: Will you try to reform the Independent Election Commission (IEC) which has been seen as very partisan in this process?
The IEC is an Afghan constitutional body, this is what the Afghan government should determine.
I can tell you that there was close co-ordination between the IEC, which was Afghan-led, and also the Electoral Complaint Commission, which was UN-backed.
Q: Will you suggest to the Afghan government that the IEC be reformed?
We will have to discuss all matters in a manner that we can ensure this second election will be more transparent and without any fraud.