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.

Ukraine 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.

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

The judge called for a break before returnomg 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.

Although a military pilot, 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. They are alleged to be 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 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 one or two 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.