However, in 1685 Charles II died and James II succeeded. In 1687 he replaced Ormonde with Richard Talbot and introduced a policy of replacing Protestant officers with Catholic ones in the Irish Army. Mountjoy was one of few Protestants remaining in the army and he could protect his Protestant soldiers and officers, such as Lundy. The Apprentice Boys of Derry shut the gates of the city against "a regiment of twelve hundred Papists, commanded by a Papist, Alexander Macdonnell, Earl of Antrim", who hastily withdrew his small force. Later, the Viceroy solicited intervention by Mountjoy and finally dispatched a strong but poorly disciplined Irish force commanded by Sir Richard Hamilton to march north against the Protestants. A stratagem prepared by Mountjoy and Lundy to assume control of Derry succeeded in embedding a small garrison of predominantly Protestant troops under the command first of Mountjoy then of Lundy, who assumed the title of governor. However, popular feeling in Derry ran so strongly in favour of the Prince of Orange that Lundy declared himself an adherent of King William III, and he obtained from him a commission confirming his appointment as Williamite governor of Derry. From December 1688 to March 1689 Lundy had the walls and the gates repaired to protect the city, refitted gun carriages and musket stocks, removed buildings and dungheaps outside the walls which might provide cover to besiegers, purchased powder, cannonballs and matchlocks, and had a protective ravelin and outworks built. Lundy's motivation cannot certainly be known. What is certain is that from the moment Derry was threatened by the troops of King James, Lundy used all his endeavours to paralyse the defence of the city. In April 1689 he was in command of a force of Protestants who encountered some troops under Richard Hamilton at Strabane, when, instead of holding his ground, he told his men that all was lost and ordered them to shift for themselves; he himself was the first to take flight back to Derry. King James, then at Omagh on his way to the north, similarly turned in flight towards Dublin on hearing of the skirmish, but returned next day on receiving the true account of the occurrence. On 14 April English ships appeared in the Foyle with reinforcements for Lundy under Colonel John Cunningham and Solomon Richards. Lundy dissuaded Cunningham from landing his regiments, representing that a defence of Derry was hopeless; and that he himself intended to withdraw secretly from the city. At the same time he sent to the enemy's headquarters a promise to surrender the city at the first summons. As soon as this became known to the citizens, Lundy's life was in danger, and he was vehemently accused of treachery. When the enemy appeared before the walls, Lundy gave orders that there should be no firing. But all authority had passed out of his hands. The people flew to arms under the direction of Major Henry Baker and Captain Adam Murray, who organised the famous defence in conjunction with the Rev. George Walker. Lundy, to avoid popular vengeance, hid himself until nightfall when, by the connivance of Walker and Murray, he made his escape in disguise.
Later life
He was apprehended in western Scotland, imprisoned at Dumbarton Castle, and then sent to the Tower of London. He was excluded from the Act of Indemnity in 1690. An effort was made to send him for trial at Derry, but this was argued against because it was evident that Lundy still retained the support of influential people there. As Reverend George Walker described this, "he had a faction for him" in the town. After an enquiry in London he was "cleared of charges of treason" and returned to military service. From 1704 to 1712 he was "Adjudent-General of the King of Portugal's forces in the Queen of England's pay" during the War of Spanish Successionwhere he defended Gibraltar against the French. In 1707 he was captured by the French, but was exchanged a year later.
Legacy
Lundy is reviled in Ulster loyalism as a traitor to this day, and is burned in effigy during the celebrations to mark the anniversary of the shutting of the gates of Derry in 1688. Much like Judas, his name has become a byword for "traitor" among unionists and loyalists. Ian Paisley regularly denounced people, including Margaret Thatcher, Terence O'Neill and David Trimble, as "Lundies".