He joined the French army, completing his training in the cavalry at the Ecole de guerre in Saumur. In 1961, seven years into the Algerian War of Independence (and just a year before independence), he changed sides, joining the National Liberation Army. After independence, he trained as an artilleryman at the Frunze Military Academy, then as a general staff officer at the Ecole de Guerre in Paris. From 1970 to 1976 he commanded a regional general staff, then he worked in the general staff operational bureau until 1988, when he became commander of the 5th military region (eastern Algeria around Constantine). In 1989, he became commander of ground forces.
Lamari's sons include Farid (a military dentist) and Mourad, an adviser at the Algerian embassy to Belgium.
In the military coup of 1992 that started the Algerian Civil War, he was prominent among the officers demanding then-President Chadli Bendjedid's resignation. According to Mohamed Samraoui, he was relieved of his functions by the next President, the short-lived Mohamed Boudiaf, in March 1992, and only regained them after Boudiaf's assassination. He was then put in charge of an anti-terrorism task force of 15,000 soldiers, the CCLAS (Centre de commandement de la lutte antisubversive). In July 1993, as Liamine Zeroual became Minister of Defense, Mohamed Lamari became Chief of Staff, a post in which he would remain for more than a decade of war.
Politically, he was considered an eradicationist, rejecting the idea of negotiation with the government's Islamist opponents. In his capacity as head of the CCLAS, he was accused by Mohamed Samraoui of ultimately controlling the Organisation of Young Free Algerians, a pro-government armed group claiming credit for various attacks on civilians.