BEFORE firing me last week from my post as his deputy special representative in Afghanistan, UN Secretary General Ban Ki-moon conveyed one last instruction: Do not talk to the press. In effect, I was being told to remain a team player after being thrown off the team. Nonetheless, I agreed.

As my differences with my boss, Norwegian diplomat Kai Eide, had already been well publicized (through no fault of either of us), I asked only that the statement announcing my dismissal reflect the real reasons. Alain LeRoy, the head of UN peacekeeping and my immediate superior in New York, proposed that the United Nations say I was being recalled over a “disagreement as to how the United Nations Assistance Mission in Afghanistan (UNAMA) would respond to electoral fraud.” Although this was not entirely accurate — the dispute was really about whether the UN mission would respond to the massive electoral fraud — I agreed.

Instead, the United Nations announced my recall as occurring “in the best interests of the mission,” and UN press officials told reporters on background that my firing was necessitated by a “personality clash” with Eide, a friend of 15 years who had introduced me to my future wife.

I might have tolerated even this last act of dishonesty in a dispute dating back many months if the stakes were not so high. For weeks, Eide had been denying or playing down the fraud in Afghanistan’s recent presidential election, telling me he was concerned that even discussing the fraud might inflame tensions in the country. But in my view, the fraud was a fact that the United Nations had to acknowledge or risk losing its credibility with the many Afghans who did not support President Hamid Karzai.

I also felt loyal to my UN colleagues who worked in a dangerous environment to help Afghans hold honest elections — at least five of whom have now told me they are leaving jobs they love in disgust over the events leading to my firing. Afghanistan’s presidential election, held Aug. 20, should have been a milestone in the country’s transition from 30 years of war to stability and democracy. Instead, it was just the opposite.

As many as 30 percent of Karzai’s votes were fraudulent, and lesser fraud was committed on behalf of other candidates. In several provinces, including Kandahar, four to 10 times as many votes were recorded as voters actually cast. The fraud has handed the Taleban their greatest strategic victory in eight years of fighting the United States and its Afghan partners.

The election was a foreseeable train wreck. Unlike the United Nations-run elections in 2004, this balloting was managed by Afghanistan’s Independent Election Commission (IEC). Despite its name, the commission is subservient to Karzai, who appointed its seven members. Even so, the international role was extensive. Part of my job was to supervise all this UN support. In July, I learned that at least 1,500 polling centers (out of 7,000) were to be located in places so insecure that no one from the IEC, the Afghan National Army or the Afghan National Police had ever visited them. Clearly, these polling centers would not open on election day. At a minimum, their existence on the books would create large-scale confusion, but I was more concerned about the risk of fraud.

Local commission staff members were hardly experienced election professionals; in many instances they were simply agents of the local power brokers, usually aligned with Karzai. If no independent observers or candidate representatives, let alone voters, could even visit the listed location of a polling center, these IEC staffers could easily stuff ballot boxes without ever taking them to the assigned location. Or they could simply report results without any votes being in the ballot boxes.

Along with ambassadors from the United States and key allies, I met with the Afghan ministers of defense and the interior as well as the commission’s chief election officer. We urged them either to produce a credible plan to secure these polling centers (which the head of the Afghan Army had told me was impossible) or to close them down. Not surprisingly, the ministers — who served a president benefiting from the fraud — complained that I had even raised the matter. Eide ordered me not to discuss the ghost polling centers any further.

At other critical stages in the election process, I was similarly ordered not to pursue the issue of fraud. The UN mission set up a 24-hour election center during the voting and in the early stages of the counting. My staff collected evidence on hundreds of cases of fraud around the country and, more important, gathered information on turnout in key southern provinces where few voters showed up but large numbers of votes were being reported. Eide ordered us not to share this data with anyone, including the Electoral Complaints Commission, a UN-backed Afghan institution legally mandated to investigate fraud. Naturally, my colleagues wondered why they had taken the risks to collect this evidence if it was not to be used. In early September, I got word that the IEC was about to abandon its published anti-fraud policies, allowing it to include enough fraudulent votes in the final tally to put Karzai over the 50 percent threshold needed to avoid a runoff. After I called the chief electoral officer to urge him to stick with the original guidelines, Karzai issued a formal protest accusing me of foreign interference. My boss sided with Karzai.

Since my disagreements with Eide went public, Eide and his supporters have argued that the United Nations had no mandate to interfere in the Afghan electoral process. This is not technically correct. The UN Security Council directed the UN mission to support Afghanistan’s electoral institutions in holding a “free, fair and transparent” vote, not a fraudulent one. And with so much at stake — and with more than 100,000 US and coalition troops deployed in the country — the international community had an obvious interest in ensuring that Afghanistan’s election did not make the situation worse. US President Barack Obama needs a legitimate Afghan partner to make any new strategy for the country work. However, the extensive fraud that took place on Aug. 20 virtually guarantees that a government emerging from the tainted vote will not be credible with many Afghans.

As I write, Afghanistan’s Electoral Complaints Commission is auditing 10 percent of the suspect polling boxes. If the audit shows this sample to be fraudulent, the commission will throw out some 3,000 suspect ballot boxes, which could lead to a runoff vote between Karzai and Abdullah Abdullah. By itself, a runoff is no antidote for Afghanistan’s electoral challenges. The widespread problems that allowed for fraud in the first round of voting must be addressed. In particular, all ghost polling stations should be removed from the books (“closed” is not the right word since they never opened), and the election staff that facilitated the fraud must be replaced.

Afghanistan’s pro-Karzai election commission will not do this on its own. Fixing those problems will require resolve from the head of the UN mission in Afghanistan — a quality that so far has been lacking.

Peter W. Galbraith served as deputy special representative of the United Nations in Afghanistan from June until last week.