A tentative deal between representatives of the San Francisco Bay Area's rail transit system and its striking unions has been reached, ending a four-day strike that left commuters scrambling for alternative transportation and caused massive gridlock on the area's highways. 

Union officials announced late Monday night that the deal had been reached. Bay Area Rapid Transit (BART) management said that limited train service would begin at 4 a.m. Tuesday, and it expected trains to be running at full strength by the afternoon commute Tuesday. The deal still must be approved by union members. 

The contentious talks between BART and its two largest unions dragged on for six months-- a period that saw two chaotic dayslong strikes, contentious negotiations and frazzled commuters wondering if they would wake up to find the trains running or not.

"The public expects us to resolve our differences and to keep the Bay Area moving," BART general manager Grace Crunican said Monday night.

Crunican said there would be no announcements on the details of the accord, but she added: "This deal is more than we wanted to pay."

The key issues were salaries and worker contributions to their health and pension plans.

Talks began in April, three months before the June 30 contract expirations, but both sides were far apart. The unions initially asked for 23.2 percent in raises over three years. BART countered, offering a four-year contract with 1 percent raises contingent on the agency meeting economic goals.

The unions contended that members made $100 million in concessions when they agreed to a deal in 2009 as BART faced a $310 million deficit. And they said they wanted their members to get their share of a $125 million operating surplus produced through increased ridership.

But the transit agency countered that it needed to control costs to help pay for new rail cars and other improvements.

BART workers walked off the job on Friday after talks broke down. Commuters endured jammed roadways and long lines for buses and ferries, as they looked for alternate ways around the region.

BART workers also walked off the job in early July, shutting down train service for nearly five days.

The Associated Press contributed to this report.