BOSTON — A major elevated highway just north of downtown Boston was temporarily closed after a beer delivery truck struck a guardrail, leaving the truck cab hanging off the road.

The Friday afternoon accident, which also involved a second smaller truck, snarled traffic for hours, and delayed commuter trains whose tracks run below the highway.

Massachusetts State Police said the crash on Interstate 93 northbound near Exit 28 was reported after 2 p.m., closing two lanes of the highway for almost two hours. The Leverett Connector highway ramp below also was closed until the dangling cab was removed at about 4:40 p.m.

Boston fire officials said the driver and a passenger got out of the cab and weren’t hurt. The driver of the smaller truck was taken to the hospital as a precaution.

State police are investigating.