In 1602, during the Polish–Swedish War (1600–11), he was released to command the Swedish forces in Livonia, who by then were in a precarious state and position. Stålarm received ambiguous orders and was unable to turn the tide. After a major defeat in September 1604, Charles removed him from the command, and Stålarm was again tried and condemned to death in the spring of 1605. He was, however, again spared, and spent the rest of his life as Charles' prisoner at Gripsholm Castle.