A burglary and assault suspect surrendered to Seattle police Friday morning after spending three hours perched in a tree in the Magnolia area, while police and firefighters watched from below.

The incident halted all rail traffic through the area, including the Sounder commuter train, as hostage negotiators urged the man to come down from his spot about 40 feet off the ground near railroad tracks south of the Ballard Locks.

The suspect, identified by police as Victor A. Mason, 38, had threatened to harm himself while up in the tree, police said.

Seattle police Detective Mark Jamieson said Friday’s events started about 2 a.m., when Mason allegedly went to his ex-girlfriend’s home in the 4600 block of 33rd Avenue, forced his way inside and assaulted her male roommate.

Unlimited Digital Access. $1 for 4 weeks.

The roommate suffered a broken foot in the attack and was taken to a hospital for treatment.

Mason came back to the house at about 5 a.m. and broke out some windows, Jamieson said. The ex-girlfriend fled, and was later located unharmed.

A police officer investigating the broken-window complaint was flagged down by a motorist who had heard someone calling for help, possibly near the railroad tracks near 34th Avenue West and Gilman Place West.

Officers found Mason in the tree about 5:30 a.m., and a hostage negotiator was called.

At least twice, the man climbed partway down the tree, then returned to his original spot, before finally coming down on his own at about 8:30 a.m., when he was taken into custody.

Police said Mason was booked into King County Jail on investigation of burglary, assault and malicious mischief — all felonies.

According to the Department of Corrections, Mason was also wanted for failing to report to his community-corrections officer after serving prison time for assault and attempted robbery.

Jack Broom: jbroom@seattletimes.com