What would happen if the President of the USA, at the last day of his term, was like "nope, I'm not leaving" and the secret service and the military were all loyal to him?

Since you're speaking specifically about the USA, such an action would be empirically unlawful on their part. How much may be yet to be determined, but let's hope we never find out.

A 100% backing by any branch of the military, let alone the entire armed services, or the secret service, will never happen. From the military perspective, subordinates are expected to carry out their duty, which in a military sense includes following their given orders, with the explicit exceptions being for when those orders are "unlawful, immoral, or unethical". Usually this doesn't come up much and the burden of proof on ethics and morality is likely to be fraught with subjective interpretation, its the unlawful portion that is easy to determine, at least speaking generally. From my experience, plenty of service members, especially outside of JAG corps, love to engage in "armchair lawyering". Regardless of political affiliation or personal feelings towards a given President, sitting or otherwise, most service members have the quality of character to recognize the blatant unlawfulness involved in such a power grab of a (should-be-)exiting President.

Even with a theoretically fully loyal military, hand-waived for your argument, it would still be a blatantly unlawful act. This would of course be compounded by any "supporting" service (secret service, armed forces, etc.) further engaging in such unlawful behavior. Eventually, even if it took a generation or two, it is more likely that the rule of law would catch up, even if the situation would require waiting out those "in power" (more like in geography) beyond natural death. The only way that would be prevented is by systematically changing what is fundamental to the constitutionally defined nature of the three branches of the federal government.

Remember those moral service members up above? Their oaths vary slightly between branch of service and rank (enlisted versus officer), but generally that swearing involves first to "...support and defend the Constitution of the United States..." long before it mentions following the orders of the President or officers appointed over said service member; those orders which are again contingent on lawful nature.

As far as someone occupying the White House, for instance, beyond their term, it is possible if given enough physical support, that person could continue occupying the space, unlawfully, for some time. Physical removal would likely prove difficult, at best, if done with enough buy-in. This seems incredibly unlikely though, as exiting Presidents are more likely to vandalize computers, such as removing all the W keys from keyboards. This is of course on a different scale entirely, one of poor collegiate pranks.

/r/NoStupidQuestions Thread