Willie Carlin (circled) in 1985 in the funeral cortege of an IRA man shot dead by the SAS in Strabane. Martin McGuinness is among those carrying the coffin

Willie Carlin was an MI5 and Army intelligence spy while handling Sinn Féin’s finances in Londonderry, writing press releases which went out in Mr McGuinness’s name and playing a key role in stealing votes to ensure Mr McGuinness’s election for the first time in 1982.

In an autobiography published this week, Agent 3007 reveals that he saw Mr McGuinness at an MI5 safe house in Limavady and heard him arguing furiously with IRA hardliner Ivor Bell who was unhappy that Sinn Féin was increasingly mopping up money and resources which otherwise would have gone to the IRA.

He also reveals that it was MI5 who acted to protect the senior Sinn Féin figure when in 2001 Mr Carlin’s former handler came out of retirement in Italy to come and ask him to give evidence to the Saville Inquiry to dispute the evidence of another agent, codenamed Infliction, that Mr McGuinness had fired the first shots on Bloody Sunday.

Sign up to our daily newsletter The i newsletter cut through the noise Sign up Thanks for signing up! Sorry, there seem to be some issues. Please try again later. Submitting...

Willie Carlin,seen here during a fleeting visit to Londonderry this year, spent more than a decade getting close to Martin McGuinness

However, Mr Carlin said that he did not believe that Mr McGuinness was himself an agent. Rather, he said: “I think the British became aware sooner than the public imagined that here was a man they could do business with.”

Writing in the book, he said: “Just before my exposure I had been rising up the ranks of Sinn Féin in Derry and was getting ever closer to Martin McGuinness, then the IRA’s chief of staff as well as one of the party’s key strategists, and later Deputy First Minister of Northern Ireland.

“My briefings to my handlers in Ebrington included information on McGuinness’s internal battles with even more hardline republicans, as well as his thoughts, ranging from participation in elections to his hostility to the extension into Scotland of the IRA’s English bombing campaign.

“Some of the secret political intelligence I had provided was mulled over and analysed by the Prime Minister, as well as her Cabinet ministers; it gave them a unique insight into the evolution of Sinn Féin and, critically, McGuinness’s own thinking.”

Martin McGuinness (left) follows the coffin of IRA man Charles English in Londonderry 1984. Photo: Pacemaker

Mr Carlin, who had left Londonderry in 1965 to join the Royal Irish Hussars, said that in 1974 he was recruited by MI5 at the former cottage of the legendary TE Lawrence – Lawrence of Arabia – and asked to return to his home city.

He said he was specifically told not to get involved with the IRA, being told that others were working in that sphere, but to get involved in Sinn Féin and feed back political intelligence.

He would later move to work for the Force Research Unit (FRU), feeding through information about Sinn Féin and in particular its two key figures in the city, Mr McGuinness and Mitchel McLaughlin.

In 1985, when his cover was blown, his life was saved by information passed from his fellow agent Stakeknife – who was on his way to interrogate and kill him.

He said that he believed his life was spared when those of other agents were not in order to save Mr McGuinness, who would have been undermined had another of his close associates publicly admitted to being an informer.

Although there was an MI5 safe house in Limavady, Mr Carlin said that his then handler, Ben, would often arrange to meet at other locations such as the Londonderry Arms in Carnlough. He said: “I wondered why, with a house at our disposal, Ben preferred to meet at other venues, and I was soon to discover the reason. I was on my way to meet him on the Antrim coast one lunchtime and as usual turned right to head up the coast road out of Limavady, which went straight past the house.

“As I drove up the road, a red Peugeot came out of the gates of the house and headed back into Limavady, coming straight towards me. I had the shock of my life, for there in the passenger seat was Martin McGuinness, bent forward as if he was reading or looking at something on his knee.

“I quickly looked the other way in the hope that the driver (whom I couldn’t place) didn’t recognise me. As I drove towards Carnlough I could feel my right foot shaking on the accelerator and sweat running down the back of my shirt...what the hell was Martin McGuinness doing coming out of an MI5 house?”

He said that several years later he was driving through Greysteel and passed a cream coloured Ford Cortina parked at the side of the road. “Sat in it were Martin McGuinness and the man I had seen a few years earlier coming out of the [MI5] house. ..this time I just looked the other way and drove on. I wasn’t as nervous, though I still couldn’t figure out what he was doing there or who the man was.”

The agent said that Mr McGuinness had been reluctant to stand as the Sinn Féin candidate in the 1982 Assembly elections but that Mitchel McLaughin had said that the elections had “given us a penalty kick” and at a Sinn Féin meeting he announced that the nominations for the election were open and then immediately said: “And I nominate Martin.”

Mr Carlin said: “Everyone there who thought they might be able to nominate someone from their cumann just sat there and said nothing.”

He went on: “I relayed back to my new handlers how Martin had been reluctant to stand, but Mitchel was working behind the scenes with Gerry Adams, Tom Hartley and others to bring McGuinness around and convince him.”

He said that it became clear that the British agencies were keen to facilitate – not stop – Mr McGuinness’s rise through the republican ranks and then his move into politics.

“A few days before the election I had a routine meeting at Ebrington Barracks with my contact John. During the meeting he introduced me to a man named Alec from London (who was not military).

“He was very interested in how I thought Sinn Féin would do at the election and was absolutely over the moon when I told him of our plan to get Martin elected. Alec made it clear to me that it was imperative that ‘Martin McGuinness gets elected to the Northern Ireland Assembly’.

“This was intriguing, and Alec stressed that there was a school of thought in London who differed from the main body of government. They believed that if Sinn Féin had elected representatives it might be possible to make some headway...Alec said they knew that Gerry Adams would undoubtedly get elected, but for me – Willie Carlin – it was vital that ‘You do all you can to get Martin elected. It’s only the first step down a very long rocky road but it’s important that by next week Martin McGuinness is an elected representative of Sinn Féin. Do you understand the importance of what I’m saying, Willie?’

“‘Even if it means breaking the law through vote stealing to achieve it?’ I asked.

“Alec just smiled. ‘Whatever it takes, Willie, whatever it takes.’ It proved to me that this new army unit was not 100 per cent tasked by the military machinations of the IRA’s Derry Brigade; it had a politico-strategic mission as well: to encourage, cajole, persuade and aid those forces in the republican movement towards political action rather than armed struggle.

“The school of thought personified by Alec got its way on 20 October 1982 when we started stealing votes...after thieving the polling cards of doctors, nurses and other medical staff from the local hospital we were voting early and often to put our ‘1’ and ‘2’ beside the Sinn Féin candidates on ballot papers. We even stole the votes of the nuns from the Good Shepherd Convent. Sinn Féin took over 10 per cent of the valid poll in the North and won five of the seventy-eight seats.”

Mr Carlin said that the scale of Mr McGuinness’s vote meant that he would have won anyway, but that his tally included more than 800 stolen votes: “Martin was ecstatic and revelled in his victory. There would be no going back now, Martin McGuinness had entered the dirty world of politics and Gerry Adams would teach him how to ride his military horse along that road.

“As celebrations went on through the night I wondered if Alec and his colleagues back in London were also toasting McGuinness’s entry into politics.”

Mr Carlin said that one of his London-based MI5 handlers, Stephen, had told him that IRA men facing jail if convicted on the word of supergrass Raymond Gilmour could escape because of political “guidance”.

He said that judges in Diplock courts “more often than not seek legal guidance from Lord Lowry as the Chief Justice” but that in this “delicate matter”, he’ll seek guidance from the judiciary and in some cases it’ll go right up through the Northern Ireland Office and even on up to the Home Office”.

Mr Carlin said that Stephen told him: “I have it on very good authority that Lord Chief Justice Lowry has sought and been given such guidance...of course, in this case his legal guidance comes with some private political guidance, too.

“It might not be in the public interest, long term, to convict.”

Mr Carlin said that Mr McGuinness was strengthened by the outcome of the trial.

The former agent was baffled when Mr McLaughlin and Mr McGuinness made it clear that they wanted him to be elected treasurer of Sinn Féin in Londonderry – a role which he said was always held by “a trusted IRA member”.

After he took over the role, he said that Mr McGuinness introduced him to a money-launderer from Donegal.

He said that Sinn Féin gave him “two sets of accounts books: one for all to see, which showed a steady income from the cumanns through various fundraising, and outgoings...the other set of books told a totally different story. As I gazed at them, I couldn’t believe what I was looking at.

“There were no receipts and no debts, just details of money coming in regularly. Even without studying them it was clear that I was now in charge of four bank accounts...they were in ordinary people’s names, none of whom I knew. A quick check at the four balances informed me that I was now the custodian of hundreds of thousands of pounds, all legal and above board.”

Mr Carlin said that he had a major role in Sinn Féin’s huge vote-stealing operation – but then was asked by his handlers to brief civil servants about how it was done, leading to them drawing up legislation which made it more difficult.

During the 1981 Fermanagh and South Tyrone by-election in which IRA hunger striker Bobby Sands was elected as an MP, Mr Carlin said that there was massive voting fraud by Sinn Féin.

“All in all there were just over a hundred activists from across the North working the entire area in mini-buses and cars. We were organised into small groups of five or six and ferried around the polling stations.

“I voted in nine different polling stations with cards that had been given to me in each area. Others claimed to have voted 15 or 16 times further up the country.

“Looking back, we could have done more because while there was no want of polling cards there was a problem with transport, but I was reliably informed that we had personated and stolen well over a thousand votes.

“Bobby Sands beat Harry West by 1,446 votes, and I was never sure if Sands would have won had we not stolen and personated on his behalf.

“However, I was jubilant, as were most nationalists – never mind republicans.

“Victory cavalcades went around Derry that night as it was clear there was a republican vote here in the North just for the taking.”

Mr Carlin said that by 1983 he was getting “more regular” visits from Northern Ireland Office officials as well as his handlers.

When his cover was blown in March 1985, Margaret Thatcher sent her ministerial jet to Aldergrove to fly him and his family out and the prime minister later met him in person.