The Parliament, firmly controlled by a pro-Western majority, voted overwhelmingly, 303 to 8, to rescind a policy of "nonalignment" and to instead pursue closer military and strategic ties with the West.
Former President Viktor F. Yanukovych, who was toppled in February and fled to Russia after months of protests in Kiev, the capital, pushed Parliament to adopt the policy in 2010, shortly after he took office.
The law had defined nonalignment as "nonparticipation of Ukraine in the military-political alliances."
The revised law, which was a priority of President Petro O. Poroshenko, requires Ukraine to "deepen cooperation with NATO in order to achieve the criteria required for membership in this organization." For now, it still seems unlikely that Ukraine will join NATO, in part because of Russia's strong opposition.
Russia has denied repeatedly that it set off the separatist violence in eastern Ukraine, but in recent months it has also made clear that preventing Ukraine from seeking NATO membership is one of its top goals. In November, President Vladimir V. Putin's personal spokesman, Dmitri S. Peskov, told the BBC, "We would like to hear a 100 percent guarantee that no one would think about Ukraine's joining NATO."
Speaking to reporters in Moscow on Tuesday, the Russian foreign minister, Sergey V. Lavrov, sharply criticized Ukraine's move. "This is counterproductive," Mr. Lavrov said. "It only pumps up confrontation, and creates the illusion that by passing such laws it is possible to settle a deep domestic crisis within Ukraine."
Repeating Russia's longstanding contention that Mr. Yanukovych's ouster was unconstitutional, Mr. Lavrov added: "A much more productive and sensible path is to start, at last, a dialogue with that part of their own people which has been completely ignored since the state coup was carried out. There is no other way. Only constitutional reform, with participation of all regions and political forces of Ukraine, can give a correct tone."
Russia has called repeatedly for a new, federalized system of government in Ukraine, which would expand the powers of regional officials. Mr. Poroshenko and his allies have been unwilling to create powerful regional governments, which might be more loyal to Moscow than Kiev. Instead, they have been drawing up a decentralization plan that would increase the authority of local officials.
Even as Russia voiced its annoyance, officials seemed to reach an agreement to resume peace negotiations in Minsk, Belarus, on Wednesday, with the participation of Ukraine, Russia and representatives of the self-declared separatist republics in the Donetsk and Luhansk regions of eastern Ukraine.
Two previous meetings in Minsk in September led to the signing of a formal truce, but it has not held. Separatist leaders told Russian news services on Tuesday that they wanted the renewed talks to focus on political autonomy for their regions. Other participants have generally put a higher priority on securing Ukraine's eastern border with Russia and ending the fighting.
In Washington, a State Department spokeswoman, Marie Harf, said that the United States had an open mind on Ukraine's joining NATO and that the alliance itself had an open door.
"Countries that are willing to contribute to security in the Euro-Atlantic space are welcome to apply for membership," Ms. Harf said, describing the general policy toward enlargement. "Each application will be considered on the merits."
David M. Herszenhorn, The New York Times