One of my favorite ways to run a long term mastermind BBEG is to run Xanatos Gambits. The name was coined from the cartoon character David Xanatos from the show Gargoyles. The idea itself is fairly simple yet will in the end be complex. The simple version is that no matter how the plan goes the plan maker will benefit in some way. Even if the heroes beat the bad guy the bad guy would still benefit long term. Sounds simple enough but when a GM tries to come up with a Xanatos Gambit it can get very tricky. Here is an example of a Xanatos Gambit taken from tvtropes.org.
As you can see there needs to be many contingency plans to make this work. A GM really needs to think of every possible way the players can approach an objective and which way it can go. When I run my BBEG I use to try to have every contingency figured out. Good gravy did I waste a lot of time because the PCs always figured out a way to circumvent whatever I came up with. They’d always do the one approach I didn’t cover and there I would sit stumped and frustrated. Now I do it the lazy and smarter way. I let the players do what they will and after the dust has settled I come up with a way to get the BBEG to come ahead. This is a little harder to do on the fly so most times after a big fight I’ll either call it a night or just have the players take a little break while I gather my thoughts. Usually after 10 minutes I’ll have something and we pick up right where we left off. Even if the players choose to kill the BBEG outright a clever GM can come up with something. Lichdom, clones, or even a child to take up the mantle can work. Be creative and let loose with your cleverness.
Xanatos Gambit: No matter the outcome the mastermind comes out ahead in one way, shape, or form.