At the beginning of the War of Independence Hayne joined the rebellion, and was a commissioned a captain of artillery, and at the same time state senator. In 1780, on the invasion of the state by the British, he served in a cavalry regiment during the finalsiege of Charleston, and, being included in the capitulation of that place, was paroled on condition that he would not serve against the British while they held possession of the city. When in 1781 the fortunes of the British began to decline, he, with all the others who were paroled on the same terms, was required to join the royal army or be subjected to close confinement. Hayne would gladly have accepted imprisonment, but his wife and several of his children lay at the point of death from smallpox. He went to Charleston, and, being assured by the deputy British commandant, Patterson, that he would not be required to bear arms against his former compatriots, took the oath of allegiance. After the successes of General Greene had left the British nothing but Charleston, Hayne was summoned to join the royal army immediately. This being in violation of the agreement that had been made, he considered that this released him from all his obligations to the British. He went to the American camp, and was commissioned colonel of a militia company. Hayne then commanded an American rebel raid which captured Brigadier-General Andrew Williamson, an American Loyalist. Colonel Nisbet Balfour, the British commander in Charleston during the 1781 siege of Charlestown, fearing that Williamson would be hanged as a traitor, sent a column to intercept the raiding party. The interception was successful. There was a skirmish resulting in the defeat of the raiding party, the release of Williamson and the capture of Hayne. Hayne, although a prisoner of war, was sentenced to death by hanging by the British, because in the opinion of the British court martial, he had broken his earlier parole not to take up arms against the Crown. His sentence was carried out in Charleston on August 4, after which Hayne was buried on the family property in Jacksonboro.