A tentative contract agreement between shippers and longshoremen in Baltimore and Philadelphia has raised hopes for an end this week to a two-month dock strike at 39 ports along the Atlantic and Gulf coasts.

The agreement, approved by local councils of the International Longshoremen's Association in the two cities Friday, sets up a vote on a new contract by 50,000 dockworkers Tuesday at deepwater ports from Maine to Texas.

"We think the chances for ratifications are very, very good," said ILA Vice President John Kopp. "It's a good contract. We got 95 per cent of what we wanted."

Baltimore and Philadelphia had been the final holdouts in the strike, which since Oct. 1 has halted nearly all "containerized" cargo - that moved in self-contained, van-sized boxes - including goods many merchants are depending on for Christmas.

Longshoremen in Baltimore expanded the strike to a general one Wednesday, cutting off all dock activity there. However, workers last night were preparing to go back to work today unloading more than 20 "break-bulk" (non-containerized) ships in that port.

Other workers won't return to their jobs until late Tuesday or early Wednesday if the contract is ratified, according to Rex Wheeler, president of the Baltimore Steamship Trade Association .

The three-year contract provides for wage increases of 80 cents per hour annually in addition to job and guaranteed income assurances. It would raise the current base wage of $8 an hour to $10.40 by Oct. 1979.

The increases would be backdated to last June 1, in effect giving a bonus of more than $500 to each union member. Employer contributions to pension and welfare benefits would increase by 91 cents to $3.75 per man-hour, according to management sorces.

The strike has meant tens of thousands of layoffs in other industries and a loss of more than $1.3 billion in the gross national product, according to Data Resources Inc., a Massachusetts economic forecasting service.

It has tied up more than $4 billion worth of freight, including such things as Christmas tree lights and components for Star Wars toys manufactured in the Far East, and gourmet cheeses and liquors from Europe.

The walkout was directed at highly mechanized containerships that carry their cargo in huge, sleek boxes that are unloaded off ships by giant cranes and placed on trucks to be hauled away.

Unions have maintained that they are responsible for a substantial reduction in jobs and work opportunities.

The ILA council in Baltimore, which represents 4,200 workers, was sharply divided over whether to accept the management offer, splitting 3 to 2 in a vote late Friday.

Garris McFadden, president of Local 333, the largest one in the council, voted against it. He told the Baltimore Sun that "we got absolutely no satifaction at all" on a guaranteed annual income provision that would assure all workers a certain minimum pay providing they work at least 700 hours annually.

Two contracts are to be voted on Tuesday. One involves local working conditions. The other is the national contract covering all East and Gulf Coast workers.