The incident began at 12:30 Tuesday afternoon as the independent contractor tried to replace and attach the sewer service line from a home to a main sewage pipe under the street.
According to a fire official, there was not sufficient cribbing -- plywood around the hole -- so dirt started caving in, burying him up to his chest. After hours of the rescue underway, the level of dirt trapping the man was down to his knees.
The man was transported to a local hospital after being pulled to safety at 2:07 a.m. He is said to be OK.
The tricky part of the rescue operation was the soil. It had the consistency of sand, so it was tough to hold back.
His foot was stuck in a squishy clay, creating a suction force fire crews had to fight against. Medical crews kept an eye on his vital signs during the long ordeal.
Crews used a vacuum truck from the city's sewer division to help remove the sand from the trench, a woodcutter to shore up the loose sand and old-fashioned human handwork to help dig him out.
Friends identified the worker as Rogelio Esparza, 41, of Hayward.
The foreman on the job said Wednesday morning that he is so grateful that crews got him out safely.
Massive rescue operation of man trapped in an Oakland sewer! pic.twitter.com/0GLTzyB9Rm— carolyn tyler (@ctylerabc7) January 12, 2016
The Associated Press contributed to this report.