E.C. Ernst Inc. said yesterday it had agreed to a plan that would remove it from Chapter 11 bankruptcy proceedings by selling a 90 percent interest in the Washington-based electrical-contracting company to The Philadelphia Bourse Inc., a large investment holding company.

The agreement is subject to approval by a federal bankruptcy court and a two-thirds majority of Ernst's stockholders, who will gather for a special meeting to consider the deal sometime in September, according to Joseph E. Griffin, Ernst's chairman.

Ernst, formerly one of the nation's largest electrical construction firms, filed for protection from its creditors under Chapter 11 of the federal bankruptcy laws in December 1978 in the face of mounting debts and constricted cash flow. It has since drastically trimmed its operations, and although it continues to lose money, Griffin said yesterday he expects the company to begin operating in the black next year as the economy recovers.

The agreement includes the repayment of Ernst's unsecured creditors at a rate of 10 cents on the dollar, $2.5 million in all, to be supplied by The Bourse, and the arrangement of a $3 million bank line for Ernst, $2.5 million of which is guaranteed by The Bourse.

In addition, the company said it had reached agreement with Travelers Indemnity Co., which provides bonding for contractors on construction projects, to continue bonding Ernst projects. Ernst owed Travelers $28 million when it filed for Chapter 11 protection, but Griffin said the company had reduced that debt to $4.5 million and has agreed to terms to pay off the remainder.

Griffin, a former Ernst executive who rejoined the company as chief executive two months before it declared for bankruptcy protection, said the agreements with Philadelphia Bourse and Travelers had been under negotiation for three years. He said he went to The Bourse because of a previous business relationship with Bourse President Howard Butcher III, an investment banker who is chairman emeritus of Butcher & Singer Inc., a major Philadelphia-based brokerage house.

Griffin said that an arrangement with Travelers, made in 1980, that allowed Ernst to again receive credit from the bonding company, had been important in continuing the company in business and had been made possible by the promise of backing by The Bourse. "I induced Travelers to start giving us credit by telling them I had Mr. Butcher in the background to help us once we came out of bankruptcy," Griffin said.

Under the agreement announced yesterday, Ernst will issue 100 million shares of common stock to replace the company's existing 4 million shares of common. The Bourse will receive 32 million shares of the new stock and all of a new issue of 15,000 shares of preferred stock, giving it approximately 90 percent of the company's outstanding equity.

Ernst has seen its sales fall from a high of $130 million a year to less than one-third that during bankruptcy proceedings, although Griffin estimated that the company's revenues would be about $70 million in the fiscal year that ends March 31.