He supported his regiment in their grievances against Parliament in 1647. When the king was seized by the army, he was entrusted to the keeping of Whalley and his regiment at Hampton Court Palace. Whalley refused to remove Charles's chaplains, and treated his captive with courtesy, so much so that Charles later wrote him a letter of thanks. In the Second English Civil War, Whalley again distinguished himself as a soldier. He was chosen to be a Commissioner (judge) at the trial of Charles I and was the fourth to sign the king's death-warrant, immediately after Cromwell. The King was executed in London on 30 January 1649.

In April 1649, soldiers in his regiment took part in the Bishopsgate mutiny. They refused to go on the Irish expedition until the Levellers' political demands were met and they received back pay. They were ordered out of London and when they refused to go, fifteen soldiers were arrested and court-martialled, of whom six were sentenced to death. Of this six, five were subsequently pardoned while Robert Lockyer, a former Levellers agitator, was shot.

Whalley took part in Cromwell's Scottish expedition, was wounded at the Battle of Dunbar, and in the autumn of 1650 was active in dealing with the situation in the north. The following year, he took part in Cromwell's pursuit of Charles II and took part in the Battle of Worcester. He followed and supported Cromwell in his political career, presented the army petition to parliament (August 1652), approved of the protectorate, and represented Nottinghamshire in the parliaments of 1654 and 1656, taking an active part in the prosecution of the Quaker James Naylor. He was one of the administrative major-generals, responsible for Lincoln, Nottingham, Derby, Warwick and Leicester. He supported the "Petition and Advice," except as regards the proposed assumption of the royal title by Oliver Cromwell, and became a member of the newly constituted House of Lords in December 1657.

On Oliver Cromwell's death, at which he was present, he in vain gave his support to Richard Cromwell; his regiment refused to obey his orders, and the Long Parliament dismissed him from his command as a representative of the army. In November 1659 he undertook an unsuccessful mission to Scotland to arrange terms with George Monck.