Your best bet is to use real world historic models as a template.
As far as I know, this has never been done in history.
Time for a history lesson!
1) As others have mentioned. Modern day Iran is a Theocracy run by the Ayatollah.
2) The Papal States. From 754 to the 1800's the Papacy controlled large sections of central Italy.
3) Many Roman Emperors, Egyptian Pharaohs, Japanese Emperors and Chinese Emperors have claimed to be gods, or descended from gods.
4) The overlap of politics and religion (including 1) 2) and 3) above) happens regularly throughout history. Some other examples.
5) Christian religious military orders
This list is by no means all inclusive. A couple things to note when applying these examples to a fictional world.
Most commonly you don't see a religion with a military AND a separate military under the control of a civilian authority. Though when you do there many examples of conflict.
The most direct example to your question is probably the religious military orders.
In general when you have the controlling military power in a region you are, by default, the government. One of the core requirements to be "the government" is to have a monopoly on violence (or at least being far more powerful than other actors).
Control. Religion was/is often used to control the populous of a given nation.
How do you get there? Religion can come to control militaries in many ways by many factors.
A state collapses and religion takes over. This can take many forms. During the middle ages this was common in Europe. Weak political leaders and small states meant that the common thread across the land was religion.
Revolution. Read up on the Iranian Revolution in the late 1970's
Conquered. The holy land was conquered by religious orders/armies during the crusades. The conquerors became the defacto political and religious leaders.
Conversion. Read up on Constantine. He was a emperor that adopted Christianity on his deathbed and had previously made it the state religion. This was largely a move to improve the stability of the Empire...but still.