MOSCOW — A Russian court on Tuesday sentenced a Ukrainian pilot to 22 years in prison after convicting her for complicity to murder in the 2014 deaths of two Russian journalists in eastern Ukraine, opening a door to a possible prisoner swap between the two countries.

The United States denounced the ruling as a show of "blatant disregard for the principles of justice."

Ukrainian President Petro Poroshenko quickly offered to exchange two Russians held in his country for the return of the pilot, 34-year old Nadezhda Savchenko. Moscow has refused to consider a swap until the legal proceedings were finished.

The Kremlin was non-committal, saying that it will be up to President Vladimir Putin to make a decision.

Upon hearing the guilty verdict, Savchenko burst into song and started to chant "Glory to Ukraine!" That was echoed by Ukrainian spectators in the courtroom in Donetsk, a Russian town near the border with Ukraine.

The judge called for a break before returning to hand down the sentence, which also included a fine for crossing into Russia illegally.

The Savchenko case has attracted strong criticism from the West and is an open wound for Ukraine, which says she was captured by Russia-backed rebels in eastern Ukraine and turned over to Russia, and therefore should be treated as a prisoner of war.

U.S. State Department spokesman John Kirby said the conviction and sentencing of Savchenko "show a blatant disregard for the principles of justice and contravene Russia's commitments under the Minsk agreements," and called for her immediate release.

Although she was an air force officer, Savchenko was fighting in a Ukrainian volunteer battalion against Russia-backed rebels when she was captured by the separatists in June 2014. She surfaced in Russia less than a month later. Moscow insists she escaped from the rebels and was captured after crossing the border by herself.

Speculation persists that Moscow could agree to exchange her for the two Russians captured in eastern Ukraine. Ukrainian officials said they were active-duty soldiers despite Russia's persistent denial that it has sent troops or equipment to bolster the rebels.

Poroshenko offered a swap in a video statement released after the verdict. He claimed that Russian President Vladimir Putin had assured him last year that "he will return Nadiya Savchenko to Ukraine after the verdict."

"In my turn, I'm ready to hand over to Russia two Russian servicemen who were captured on our territory for their part in an armed aggression against Ukraine," Poroshenko said. The Russian men are now on trial, and Poroshenko said he will be willing to hand them over after the verdict is in.

Fighting between Russia-backed separatists and government troops in eastern Ukraine, which flared up after Moscow's annexation of Ukraine's Crimean Peninsula, has killed more than 9,100 people and left the rebel-held areas isolated from the rest of Ukraine.

The judge dismissed all defense arguments and said he had no reason to doubt the testimony of the separatist rebels.

The sentencing capped a two-day hearing in which Judge Leonid Stepanenko recounted the case in great detail and in a monotonous voice, sending some spectators to sleep. The lawyers passed the time looking into their phones or talking to Savchenko, who was confined in a cage. One lawyer read a magazine on the American Civil War. Savchenko smiled at her sister who was in the courtroom.

After the judge pronounced sentence, Savchenko shouted that he should have made it 23 years as prosecutors had asked. And then she sang.