The driver of a tractor-trailer was pinned inside the crushed cab of his rig for more than four hours yesterday after an early-morning accident on the Capital Beltway near Landover, Maryland state police said.

About 20 Prince George's County Fire Department rescue workers labored from 2 to 6 a.m. to free John Adams, 27, of Hickory, N.C., after his truck slammed into the rear of another tractor-trailer. Adams was in fair condition late yesterday at Prince George's General Hospital following an operation for a leg injury.

"It's a miracle that he was even alive," said fire department spokesman Capt. Jim Mundy. "Other than the leg injury, he seemed okay. After we got him out, he stood up himself. He was conscious through the whole thing."

Adams could not be reached for comment yesterday.

State police said the accident occurred when Adams' tractor-trailer, which was going north on the Beltway, crashed into another tractor-trailer directly in front of him.

Police had not determined the cause of the accident yesterday. "We don't know whether he was speeding or asleep when he plowed into the other truck," said state police Sgt. John Knox.

The other driver, William S. Tart Jr., 23, of Dunn, N.C., was not injured.

As a result of the crash, the cab of Adams' rig "looked like an accordion" stuck against the back of Tart's truck, according to Mundy.

For the first hour or so after the collision, firefighters and rescue workers tried to free Adams by using the cranes on tow trucks to pull the front portion of the truck away from his body. When that didn't work, the squad tried to free Adams by having another tractor-trailer pull the metal with chains. Finally, the squad used saws and a portable hydraulic rescue device to release him.

The accident caused a slight delay in early-morning traffic, according to Knox, with cars lined up for a quarter-mile until about 7 a.m., when Adams' trailer was moved off the highway.