Dex One and SuperMedia, two money-losing phone-book publishers, won a judge’s permission on Monday to merge and exit bankruptcy about three years after the companies previously left court protection.

Dex One is based in Cary.

Shareholders of both firms approved the merger in March.

The approval clears the way for a stock-for-stock merger of the two companies with Dex One shareholders owning some 60 percent of the combined company.

The headquarters of the combined company, which will take the Dex One name, will be in Texas where SuperMedia operates.

Some layoffs are expected. Among those who will lose a job is Alfred Mockett, the CEO of Dex One. He will step down once the merger is complete. Peter McDonald, the CEO of SuperMedia, will be the top executive of the combined company, which will continue the Dex One name. Alan Schultz, the Dex One board chair, will direct the combined company of some 5,800 employees.

U.S. Bankruptcy Judge Kevin Gross approved a plan to combine the two companies, whose creditors also had voted for the merger. The companies plan to complete the final legal documentation and leave bankruptcy by Tuesday, less than two months after they filed for protection from creditors.

The merger will allow Dex One, formerly known as R.H. Donnelley Corp., and SuperMedia, formerly Idearc Inc., to save as much as $175 million a year, Dex One General Counsel Mark W. Hianik said in an affidavit. The companies spent less time in bankruptcy than previously because most of the reorganization work was done before they filed their cases.

“I acknowledge the tremendous efforts that went into this case in spite of the fact that I rarely saw you,” Gross said in U.S. Bankruptcy Court in Wilmington, Delaware. “The benefits are absolutely apparent.”

Creditors will be fully repaid and shareholders will get equity in the new, combined company, Dex One attorney Marc Kieselstein and SuperMedia attorney Sean A. O’Neal said in court today. The combined company will have 5,800 employees.

SuperMedia, based in Dallas, ended its previous bankruptcy in December 2009. Dex One exited the following month.

SuperMedia had net income of $314 million in the 12 months ended Sept. 30, after losing $967 million the previous two years, according to data compiled by Bloomberg. Dex One had income of $62 million in 2012 after losing $518 million in 2011.

The companies will be able to use $1 billion in net operating losses from Dex One to save about $400 million on future income taxes, SuperMedia Chief Financial Officer Samuel D. Jones said in court papers.

The companies publish yellow pages and online directories and provide advertising services online and through direct mail. 

(Bloomberg news contributed to this report.)