Speaking in the northern city of Kaduna at the 40th anniversary and passing out ceremony of cadet officers of the Nigerian Defence Academy at the weekend, Obasanjo urged officers never to "dabble in roles for which you have neither training nor constitutional rights and legitimacy."
He urged them to continue to safeguard the territorial integrity of the country and contribute towards the sustenance of democracy, it said.
"You have so far demonstrated your commitment to this sacred responsibility and you must continue to dutifully work towards the sustenance of our democratic experiment.
"This is the way to retain and enhance the credibility, dignity and strength of the armed forces," said Obasanjo, a former military head of state.
Obasanjo, who ceded power to an elected civilian regime in 1979 and retired from the army, returned to power 20 years later as the country's first elected civilian president after decades of military rule.
In recent years, many military experts, including former top military officers, have openly condemned the politicisation of the armed forces.
Former army chief Victor Malu once said that involvement of the military in politics, had corrupted military officers and affected discipline.