The unidentified man gave himself up at midmorning and was taken into custody by police.
The man, wearing a ski mask and brown fatigues, had the flag in one hand and the gun in the other when officers arrived on the Highway 101's La Cumbre Avenue overpass just after 7:10 a.m., said police Sgt. Lorenzo Duarte.
No shots were fired. A police special weapons and tactics team and a crisis negotiation team used a bullhorn to communicate with the man. Nearly three hours into the siege he put the handgun on the ground and he later walked backward to police officers.
As for the man's motive, Duarte said, "The reason appears to be anti-war, but I don't know the specifics."
The freeway, a major route along the California coast, was shut down and the Highway Patrol reported at 10 a.m. that traffic was backed up at least three miles in each direction.
Motorists stuck on the freeway got out of their vehicles and chatted or waved at media helicopters. The freeway was reopened after the man's arrest.
Santa Barbara is 90 miles northwest of Los Angeles.