Civil war and other conflicts
When Empress Matilda, along with her half-brother Robert of Gloucester and her supporters, landed in Sussex in 1139 to press her claim for the throne, John seems to have only been a nominal supporter of Stephen. His loyalty to the king seems to have been in sufficient doubt that his castle at Marlborough was briefly besieged. In 1140 the castle of Marlborough was also threatened by Robert fitzHubert, who had captured Devizes castle, but John tricked him into imprisonment and sold him to earl William of Gloucester. On the same year, king Stephen tried to appoint a breton governor in Wiltshire, causing the disfavour of both John and the Salisburys. When Stephen was captured at the Battle of Lincoln in 1141, John definitively switched allegiance to Matilda.
In September 1141, Matilda fled the siege of Winchester and took refuge in the Marshal's castle at Ludgershall. While covering her retreat from Winchester, John was forced to take refuge from the enemies at Wherwell Abbey. The attackers set fire to the building, and John was seriously injured by dripping lead from the melting roof, to the point that his pursuers thought him dead. Although he was splashed, burnt, and lost an eye, John was not dead and he stumbled back home to Marlborough on foot, in a 25 miles long march. In 1142 John is seen at the Empress's side again at Oxford, where his brother William Giffard was acting as a chancellor.
In the mid 1140s (probably starting in 1145), John entered in conflict with Patrick of Salisbury in a matter of local power. Patrick launched a series of aggressive sieges, which John resisted; the first mentioned's eventual success might explain Matilda's decision to make him an earl. The matter was ultimately resolved by a marriage between John and Sybil, Patrick's sister, and John was forced to annul his pre-existing marriage to a woman named Adelina on the grounds of consanguinity.
In 1152, with the civil war dying down, John tried to increase his control in the Kennet Valley. This caught the attention of King Stephen, who promptly besieged him at Newbury castle. Stephen gave John a day to think about surrender, but Marshal asked for more time. As a consequence, the king demanded that one of John's sons was given to him as a hostage in order to prevent trickery. John agreed and sent out his youngest son, William Marshal, but he had no intention of actually keeping the agreement. Stephen sent John a messenger, stating the intention to hang William if he didn't change his mind, but John observed that he could make more and better sons anyway. Stephen, however, didn't want the young boy to die, and took pity on him (perhaps having lost two of his own sons). Little William was kept at the king's court, and was reunited with his mother Sybil after the end of the civil war in 1153.