A 40-day strike that shut down the network of buses, trolleys and subways serving 435,000 passengers a day here ended today when the Transport Workers Union and the regional transit authority announced that they had reached a tentative agreement on a new contract.

The announcement was made this evening by the Southeastern Pennsylvania Transportation Authority, or Septa, and Local 234 of the Transport Workers Union.

Service is to be restored starting at 4 A.M. Saturday, and to persuade people to return to the habit of using public transportation, rides will be free through Tuesday, the transit authority said.

''I'm pleased to say Septa is coming back to life again,'' said the general manager of the nation's fifth-largest transit system, Jack Leary, The Associated Press reported.