According to the Montana Instructions:
A Resident of Montana is an individual that lives in or maintains a permanent home in Montana.
A Nonresident of Montana is an individual that is not a resident or part-year resident of the state.
A Part-Year Resident is an individual that moved into or out of Montana during the tax year with the intention of establishing permanent residency in the new State.
What if my spouse and I have different residency?
If one spouse is a resident and the other is not, you should file separate returns for each spouse required to file. To file separate returns within your account, you can file the federal return and wait for the return to be accepted. Then, change the filing status for the primary taxpayer and file a separate return for the first spouse. The second spouse will need to create a new account and file the separate state return in that account (if required to file).