Hanger, of Hershey, was a utility commissioner under Gov. Robert P. Casey, and was secretary of the Department of Environmental Protection under Gov. Ed Rendell.
The TV campaign waged by Wolf, a wealthy businessman from York, prompted him to withdraw, Hanger said.
"Tom Wolf's television campaign has been startlingly effective, and he has taken a commanding lead, having reached support of 40 percent or more," he said in a statement. "With no path to victory, to press on could cause damage to the issues and people for which we campaigned."
He praised all of his five remaining opponents and said he was sure that whoever won the primary would defeat Gov. Corbett, a Republican, in November.
Hanger never broke single digits in the most recent independent public opinion polls, but he had a committed core of liberal activists, and won the straw poll at the state's Progressive Summit of left-leaning groups on March 8 in Harrisburg.
He became identified with the cause of legalizing marijuana, which he mentioned at every campaign appearance and pushed during debates.
Hanger said he approached the issue as a matter of social justice - it made no sense for the authorities to lock up so many people for pot possession, especially, he said, because African Americans were disproportionately arrested.
Hanger advocated decriminalization of possession of small amounts of the drug, immediate legalization of medical marijuana, and then, within two years, full legalization with taxes. Recent polls by Mercyhurst and Quinnipiac Universities showed growing support for these ideas in Pennsylvania. Hanger will no longer be the one to carry the torch.
The remaining candidates are Wolf, U.S. Rep. Allyson Y. Schwartz, state Treasurer Rob McCord, former DEP secretary Katie McGinty, and former state Auditor General Jack Wagner of Pittsburgh.