A Royal Navy submariner on a Faslane-based vessel has admitted meeting two people he thought were Russian secret agents to discuss the movements of British nuclear submarines.

Petty officer Edward Devenney, 30, was a submariner on HMS Vigilant, a Trident nuclear submarine, when he decided to pass on the classified information. Yesterday at the Old Bailey, Devenney, who is from Northern Ireland, admitted breaching the Official Secrets Act and misconduct in a public office by collecting classified coding programmes that could be useful to UK enemies.

He contacted a foreign embassy to try to pass to Russia the "crypto material" –programmes used to encrypt secret information – and information linked to the operation of HMS Trafalgar and two nuclear submarines.

However, the two people he eventually met were from British secret services.

Devenney admitted collecting information for a purpose prejudicial to the safety or interests of the state between November 18 last year and March 7 this year.

He denied a second count of communicating information to another person, and this will not be pursued by prosecutors.

Devenney, who has served with the Royal Navy for more than 11 years, was with HMS Vigilant at Devonport dock in Plymouth when his activities raised the suspicions of his senior officers, a court heard earlier.

Vigilant's £300 million refit at Devonport involved upgrading the reactor core in a refuelling which will last the submarine the rest of its life. The refit was completed earlier this year and the submarine was returned to Faslane, from where it has been taking part in sea trials.

Devenney was a prolific user of Twitter, describing himself on the social network as "Edward Devenney. Nearly 30. Royal Navy Submarine Service. Labour supporter. Lover of ducks and chickens. Trainee Feminist."

The court heard Devenney had tweeted "Cameron is putting his political pride before the best interests of the Service", and, when the Prime Minister visited HMS Vigilant in Scotland, said "Cameron visited my submarine today but I wasn't there. Wish I was to give him a piece of my mind." Mr Cameron made the trip in February.

Devenney, who was remanded in custody, will be sentenced on December 12 at the Old Bailey, when parts of the hearing will be held in secret.

At an earlier bail hearing, prosecutors said Devenney had wanted to "hurt the navy" by disclosing the secrets.

Westminster Magistrates Court was told the submariner had been drinking heavily at the time and was angry that a degree course he had been due to take had been "binned" because of budget cuts.

Devenney, the court heard, did not expect any reward from passing on the information.

A witness for the Ministry of Defence assessed the disclosures and concluded the information could be useful to an enemy.