The Army had 2,553 cases, the RAF 965, the Navy 366 and the Royal Marines 58, the annual summary of mental health showed. The 3,942 new cases were up from 3,103 the year before.
The MoD said the rise was down to more people coming forward and a change in the way the figures are collected, which sees all new episodes of care recorded rather than only first attendances.
The figures showed there were 249 cases of post-traumatic stress disorder (PTSD) following deployment to either Afghanistan or Iraq.
A total of 30 service personnel had to be evacuated from Afghanistan with psychiatric problems. In the Army, those who had been to Afghanistan were more than six times as likely to suffer PTSD and more than three times as likely to report depression.
Overall there were 293 alcohol-related cases and 835 cases of depression.
Women were more than twice as likely to suffer mental health problems than men, and officers were half as likely to suffer than other ranks. Those aged 20-24 were most at risk.
Out of every 1,000 serving men and women 19.6 were diagnosed with a problem, or one in 50.
The data also showed that in 2009 there were 164 medical discharges for a mental disorder. Figures for last year will be available in July. A MoD spokesman said: "The mental health of our Armed Forces is a top priority.
"We recognise that the stigma associated with mental health disorders can be a huge barrier to personnel coming forward for treatment and addressing it is every commander's responsibility. The data we have does suggest that more Armed Forces personnel are coming forward, which is vital so that diagnosis and treatment can be performed by fully trained and accredited mental health personnel."
A report by Professor Simon Wessely, of King's College London, published in the Lancet last year concluded that the incidence of PTSD among actively deployed troops was about 4 per cent, with one in five respondents showing signs of other mental health problems. A report by the MOD last year also found British forces who have served in Iraq and Afghanistan are more likely to have serious alcohol problems than other troops.