It has been a grim few years for the banks that Benjamin M. Lawsky regulates. He threatened to pull their licenses, fined them hundreds of millions of dollars and forced dozens of their employees to resign.

Now, much to Wall Street’s delight, the New York State regulator will be leaving government to start his own legal and consulting firm.

Mr. Lawsky, a onetime Democratic aide and former federal prosecutor, announced on Wednesday that he would vacate his post as the state’s overseer of banking and insurance in late June, capping a polarizing four-year tenure that shook up the sleepy world of financial regulation in New York. With cases against the likes of Deutsche Bank, Standard Chartered and PricewaterhouseCoopers, Mr. Lawsky cemented his reputation as the new sheriff of Wall Street — and as a burr in the side of the financial industry and even some fellow regulators.

Mr. Lawsky’s departure will set off speculation about whom Gov. Andrew M. Cuomo will select as his successor. Although those discussions are in their infancy, people briefed on the matter said, names of possible contenders are circulating: Michele Hirshman, a former federal prosecutor and a partner at Paul Weiss; Hector Gonzalez, another former prosecutor who is a partner at Dechert; Marshall L. Miller, a senior Justice Department official; and Jonathan Schwartz, a former JPMorgan Chase executive who is now the general counsel of Univision. Bridget M. Healy, ING’s top lawyer in the United States, is also thought to be in the mix.