BOWDOINHAM, Maine — A small airplane crashed Tuesday morning when the pilot tried to make an emergency landing on the southbound side of Interstate 295 — but he and his passenger were able to walk away mostly unharmed, officials said.

Pilot John Gayley from Bowdoin told investigators that his 1947 Cessna fixed wing started having engine problems shortly after he took off from the Merrymeeting Field in Bowdoinham with passenger Rodney Voisene of Bowdoin.

Gayley said that his engine stalled when he tried to switch fuel tanks, according to Stephen McCausland, spokesman for the Maine Department of Public Safety.

Gayley landed the plane in the southbound lane at around 10:15 a.m., against traffic, but crashed into the guardrail, flipping the aircraft’s tail into the air, McCausland said.

“One vehicle had to swerve to avoid the plane as it landed,” he said.

Both the pilot and passenger walked away from the wreck, but each had minor injuries and were taken to local hospitals. Gayley had cuts and scrapes to his face, and Voisene had minor cuts to his arm, McCausland said.

The plane was traveling to Twitchell’s Airport and Seaplane Base in Turner, Maine.

The plane’s engine compartment was crushed, but the wings appeared intact.

Firefighters at the scene initially kept people away from the plane because it was leaking fuel. Traffic after the crash was reduced to one lane, and a wrecker was scheduled to remove the aircraft Tuesday afternoon.

The FAA spent part of Tuesday investigating the crash.

Watch for updates.