The president of District Cablevision Inc. signed a 15-year contract with the city yesterday, committing the firm to its pledge to build a $130 million system that would bring cable to every District home in four years.

Mayor Marion Barry, council members and city employes looked on as District Cablevision president Robert L. Johnson signed the agreement in the mayor's conference room.

The action was the final step in a cable-franchising process that began two years ago and was characterized by bitter competition among three local cable firms, controversy over the evaluation of bidders, lengthy public hearings and a lawsuit.

District Cablevision has promised that some homes in each of the city's eight wards will be wired for a 78-channel residential cable network by the spring of 1986, provided that the company obtains about $80 million in financing. One District Cablevision official indicated yesterday that raising the money -- which will occupy the firm's attention for the next two months -- will be "extremely difficult."

District Cablevision has one year to secure adequate financing and 18 months to begin construction or the franchise agreement will be terminated. In addition the city will require the company to establish a $2 million security fund while the system is under construction and has the authority to terminate the agreement if the company does not comply with the terms of the agreement.

As a symbol of what cable would mean for the District, Johnson brought a shiny red apple to the ceremony.

The cable system is "something that I think is going to be fruit for the business community, fruit for the entertainment community, fruit for the social services community and I think fruit for employment opportunites for all of the people of this city," Johnson said.

The mayor, who signed the agreement in December, said the agreement was "fair and equitable to both parties."

"Bob Johnson, we're delighted that you've been able to pull this off," said Barry. " . . .The cynics and soothsayers of doom predicted that we would never get to this point but we are here . . . and Bob, thank you very much for getting around to sign this contract."

The mayor was referring to the weeks of speculation over whether the company would actually sign the agreement before March 12, the deadline for the firm to sign the agreement or it would have automatically terminated. District Cablevision officials had delayed signing, saying that a lawsuit filed by Capital City Cable, a losing bidder, had had a chilling effect on District Cablevision's ability to raise money.

That obstacle was removed last week when the two companies reached an out-of-court-settlement that allows Capital City to receive up to $300,000 in cash payments and an option to purchase $100,000 in stock.

District Cablevision has said it needs to secure $50 million in bank financing and $30 million through limited partnerships, a method by which the firm sells an interest in the system to investors who sell their interest back to the firm after a designated period.

Yesterday, during a press conference held before the cable agreement was signed, Herbert P. Wilkins, a member of the firm's board of directors, said he is "confident that we'll raise the money" but added that the firm would have to overcome some "negative feelings" in the financial community.

"The negative feelings are that this is America and this is a black-owned company trying to raise $100 million and that is it in a nutshell," Wilkins said.

In addition, Wilkins, president of Syndicated Communications Inc., a communications company that helps minorities secure capital, said that proposed changes in the tax laws would eliminate some of the tax benefits normally associated with limited-partnership arrangements, thus discouraging investors.

"Minority control and the market for limited partnerships are double negatives," Wilkins said. "I think it will be extremely difficult . . . but we have one of the best structures for a cable television deal."

District Cablevision's minority investors make up about 44 percent of the company and Tele-Communications Inc. and United Cable, major cable system operators, make up 20 and 10 percent respectively.

City Council member Wilhelmina J. Rolark, who had pushed for major minority involvement in the franchise, said she is confident that the company will maintain its minority investors and raise the money. "The climate is right and they just have to marshal their strengths," she said.

Johnson said that for "all practical purposes" his firm is minority-owned and operated and that despite Wilkins' assessment, the firm's official position is that, "We don't think the racial issue is a problem.