More than half of those caught had used cocaine – a class A substance – and one in three had taken cannabis.
The vast majority of failed compulsory drug tests were recorded by the Army, which has more personnel than the Royal Navy and the RAF put together.
Between January 2009 and September 2011, 1,286 soldiers were found to have taken illegal substances, the Ministry of Defence (MoD) revealed in response to a Freedom of Information request by the Yorkshire Post.
The Navy recorded 109 failed tests, with the number increasing from 34 in 2009 to 44 in 2010 before falling to 31 in 2011.
Test failures in the RAF are rising year on year, from 12 in 2009 and 28 in 2010 to 38 in 2011. At least 45 of the 78 cases involved cocaine.
The total number of UK service personnel has shrunk from about 188,400 to 186,400.
Tory MP Patrick Mercer, a former Army commanding officer, said: “The number of people they are testing is getting smaller because the size of the Armed Forces is decreasing, so if numbers are rising that is concerning.
“But these statistics may also be a reflection of how detection methods have either changed or are improving. Or it is probable that there has been a different approach taken at some level of the RAF.
“When I was a commanding officer, I knew how to keep down the compulsory drug test statistics – you made sure that the battalion was tested on a Friday morning.
“Other battalions took a different approach and showed zero tolerance, and I suspect that the wider adoption of that approach may explain the figures.”
The MoD said 1,272 soldiers, 103 Navy personnel and 62 RAF servicemen had been discharged from the Armed Forces since January 2009 for taking illegal drugs.
A spokesman said: “The Armed Forces do not tolerate the taking of illegal drugs within their ranks, as it is incompatible with military service.”