UNITED NATIONS — Russia on Saturday vetoed a United Nations Security Council resolution that declared a planned Sunday referendum on secession in Crimea illegal, casting the sole vote against it.

China, Russia’s traditional ally on the Council, abstained. As a permanent member of the Council, Russia has the right to reject any measure proposed in the body.

The Russian ambassador, Vitaly I. Churkin, preceded his no vote by saying that Russia would respect the results of Sunday’s referendum, but he did not say anything about exactly what it would do afterward. Mr. Churkin described the referendum as an “extraordinary measure,” expressing the Crimean people’s right to self-determination, made necessary by what he said was an “illegal coup carried out by radicals” in Ukraine. He was referring to the ouster of President Viktor F. Yanukovych, a Russian ally, in February, which precipitated the current crisis.

No one had expected the resolution to pass. Western diplomats had hoped that China would not side with Russia, which would push Moscow into an uncomfortable corner. The measure was worded carefully to persuade China to abstain — “a deliberately reasonable text,” as the British ambassador, Mark Lyall Grant, put it — and it succeeded in doing so, but only after placing Beijing in the tightest corner of all.