Background Violent off ending by veterans of the Iraq and Afghanistan conflicts is a cause for concern and there is much public debate about the proportion of ex-military personnel in the criminal justice system for violent offences. Although the psychological effects of conflict are well documented, the potential legacy of violent off ending has yet to be ascertained. We describe our use of criminal records to investigate the effect of deployment, combat, and post-deployment mental health problems on violent off ending among military personnel relative to pre-existing risk factors. Methods In this cohort study, we linked data from 13 856 randomly selected, serving and ex-serving UK military personnel with national criminal records stored on the Ministry of Justice Police National Computer database. We describe off ending during the lifetime of the participants and assess the risk factors for violent off ending. Findings 2139 (weighted 17.0%) of 12 359 male UK military personnel had a criminal record for any offence during their lifetime. Violent off enders (1369 [11.0%]) were the most prevalent off ender types; prevalence was highest in men aged 30 years or younger (521 [20.6%] of 2728) and fell with age (164 [4.7%] of 3027 at age >45 years). Deployment was not independently associated with increased risk of violent off ending, but serving in a combat role conferred an additional risk, even after adjustment for confounders (violent off ending in 137 [6.3%] of 2178 men deployed in a combat role vs 140 (2.4%) of 5797 deployed in a non-combat role; adjusted hazard ratio 1.53, 95% CI 1.15-2.03; p=0.003). Increased exposure to traumatic events during deployment also increased risk of violent off ending (violent off ending in 104 [4.1%] of 2753 men with exposure to two to four traumatic events vs 56 [1.6%] of 2944 with zero to one traumatic event, 1.77, 1.21-2.58, p=0.003; and violent off ending in 122 [5.1%] of 2582 men with exposure to five to 16 traumatic events, 1.65, 1.12-2.40, p=0.01; test for trend, p=0.032). Violent off ending was strongly associated with post-deployment alcohol misuse (violent off ending in 120 [9.0%] of 1363 men with alcohol misuse vs 155 [2.3%] of 6768 with no alcohol misuse; 2.16, 1.62-2.90; p<0.0001), post-traumatic stress disorder (violent off ending in 25 [8.6%] of 344 men with post-traumatic stress disorder vs 221 [3.0%] of 7256 with no symptoms of post-traumatic stress disorder; 2.20, 1.36-3.55; p=0.001), and high levels of self-reported aggressive behaviour (violent off ending in 56 [6.7%] of 856 men with an aggression score of six to 16 vs 22 [1.2%] of 1685 with an aggression score of zero; 2.47, 1.37-4.46; p=0.003). Of the post-traumatic stress disorder symptoms, the hyperarousal cluster was most strongly associated with violent off ending (2.01, 1.50-2.70; p<0.0001). Interpretation Alcohol misuse and aggressive behaviour might be appropriate targets for interventions, but any action must be evidence based. Post-traumatic stress disorder, though less prevalent, is also a risk factor for violence, especially hyperarousal symptoms, so if diagnosed it should be appropriately treated and associated risk monitored.