THIS MONTH the Bush administration set a test for its democracy policy in the oil-rich Muslim nation of Azerbaijan, which lies on the Caspian Sea between Russia and Iran. President Bush had challenged the country's autocratic but pro-Western president, Ilham Aliyev, to hold a free and fair election for parliament and pledged that if he did so, it would "elevate our countries' relations to a new strategic level." The election took place Sunday -- and Mr. Aliyev flunked. Western election observers described the vote counting as "bad" or "very bad" in more than 40 percent of the polling stations they watched; a U.S.-backed exit poll showed that the losing candidate was declared the winner in at least half a dozen districts. Mr. Bush must now consider the converse of his offer: Given Mr. Aliyev's failure to deliver, the status of a "strategic" ally should be withheld from Azerbaijan.

Such a step won't be easy for Mr. Bush, despite his democracy doctrine. Thanks to a newly completed pipeline, Azerbaijan is about to become a major supplier of oil to the West, and the Pentagon is eager to upgrade a military relationship that already allows U.S. overflights to Iraq and Afghanistan. The Western-educated Mr. Aliyev is warmly regarded by many U.S. officials; when he was elected president two years ago amid blatant fraud and police violence against demonstrators, Washington's first reaction was a congratulatory phone call from the deputy secretary of state.

To its credit, the administration has reacted differently to this election. A statement issued Monday called the polling "an improvement" but deplored "major irregularities and fraud." Behind the scenes, U.S. officials pressed Mr. Aliyev to take action. Yesterday his government responded by annulling the results in two of 125 districts and ordering a recount in another where an opposition leader was probably cheated of victory. Mr. Aliyev also promised to prosecute officials who had engaged in fraud, and aides said opposition demonstrations planned for today would be allowed to proceed peacefully.

Opposition hopes for a "color revolution" that will oust Mr. Aliyev probably won't succeed, if only because the president, unlike his counterparts in Georgia and Ukraine, has the support of most of the country. The president's modest responsiveness to U.S. cajoling and his frequent assertions that he wishes to democratize his country argue for a continued effort by the administration to work with him. Yet it would be a great setback for the democracy agenda if Mr. Aliyev is seen by his citizens and neighbors to be rewarded -- via a White House visit or new military agreements -- for an election so obviously flawed. If Azerbaijan is truly to become a strategic American ally, it must do so as a genuine democracy. The shams of an autocrat, however friendly, aren't good enough.