A Canadian man wanted in connection with the slayings of two registered sex offenders in Maine fatally shot himself Sunday night after being cornered by police on a bus approaching South Station in Boston, authorities said.

Stephen A. Marshall, 20, shot himself in the head with a .45 caliber handgun when officers stopped the bus he was on and climbed aboard at about 7:25 p.m., said David Procopio, spokesman for the Suffolk County district attorney.

Officers heard a gunshot and found Marshall with a massive head wound in a window seat 13 rows behind the driver, Procopio said.

He was rushed to Boston Medical Center, where he was pronounced dead at 11:24 p.m., a hospital spokeswoman said.

No one else on the bus was injured, Procopio said, but five passengers who were splattered with blood were taken to area hospitals to be examined.

“This is the suspect who is wanted in connection with two separate homicides in Maine,” Procopio said.

Police cornered Marshall on a Vermont Bus Lines coach that he had boarded in Bangor, Procopio said.

The bus was on a ramp leading onto Interstate 90, a short distance from its destination at Boston’s South Station.

Paramedics found a second handgun in Marshall’s possession when they treated him for his injuries, Procopio said.

Maine State Police alerted Boston authorities after discovering Marshall’s pickup truck abandoned in Bangor and then finding bullets linked to him in the restroom of a bus station, said Stephen McCausland, spokesman for the Maine Department of Public Safety.

Police believed he was headed to Boston, but law enforcement officials in Maine and Canada continued searching Sunday night for the teenager suspected of gunning down two sex offenders in their homes early Easter morning.

State police Sunday afternoon had issued an alert for Marshall, of Cape Breton, Nova Scotia, describing him as a “person of interest” considered to be “armed and dangerous.”

The shooting victims were identified as Joseph L. Gray, 57, of 233 West Main St. in Milo and William Elliott, 24, of 953 Main St. in Corinth.

A woman who reportedly witnessed the Corinth shooting gave detectives a license plate number and a description of the truck in which the gunman fled the scene. Bangor police found a 2002 Toyota Tundra pickup bearing that license plate at about 1 p.m. Sunday behind Sawyer Arena in Hayford Park in Bangor.

The mud-splattered silver truck was parked next to a trash container behind the skating rink on Thirteenth Street. It is registered to a Ralph A. Marshall of Houlton. Stephen Marshall had come to Houlton for the first time to meet his father, McCausland said. Marshall was using his father’s pickup.

No vehicle was reported stolen from the Aroostook County community, according to Cpl. Tom Donahue of the Houlton Police Department.

No one answered at the truck owner’s last known Houlton address when attempts were made Sunday to contact him.

The truck was taken to the state police crime lab in Augusta for processing after detectives photographed it and went through two green trash bags in the trash container. A police dog and its handler searched the woods behind the arena, then returned to a patrol car to wait for the state police tow truck.

Gray was shot at about 3 a.m., and Elliott was killed approximately five hours later, Maine State Police Lt. Jackie Theriault said at a press conference Sunday afternoon at the Corinth Snowmobile Club.

The state police set up a command post at the club, located less than a half-mile north of Elliott’s trailer on Route 15. A mobile command vehicle, purchased with Homeland Security funds that Bangor police received last summer, was parked in the club’s driveway.

Theriault said the victims were registered sex offenders and that as a precaution the Maine Sex Offender Registry, which is maintained by the state police and contains photos, names and addresses of more than 2,200 Maine registered sex offenders, had been taken offline. The state police official did not elaborate.

Elliott was convicted in 2002 in 3rd District Court in Newport of sexual abuse of a minor and sentenced to four months in jail. As a result of that misdemeanor conviction, he was ordered to register as a sex offender for 10 years.

Information on Gray’s criminal history was not available Sunday.

The father of the Corinth victim said Sunday night in a phone interview with the Bangor Daily News that his son was awakened about 8 that morning by a knock on the door.

“He went to the door, opened it up, and the guy just started shooting,” said Wayne Elliott, 61, of Charleston. “He kept shooting after he fell to the floor.”

The elder Elliott said that his son’s girlfriend witnessed the shooting and was able to describe the shooter to police.

“I loved him very much and he loved me, and we always told each other that,” Wayne Elliott said. “I saw him day before yesterday, and yesterday talked to him on phone. I had no idea anybody hated him this much. He had all kinds of friends and was a hard worker.”

William Elliott operated a small junkyard from his rented residence, his father said. The trailer, located in a gully on Route 15 in Corinth, was surrounded Sunday by tires, a school bus, appliances and other discarded items.

In Milo, [18] miles from the junkyard, yellow police tape blocked off the long driveway to Gray’s neat white, ranch-style home nestled in a pine wood. A white mailbox nearby, decorated with bright, red cardinals, had the number 233 stamped on it in black.

Detectives said that in addition to the state police, the Bangor Police Department, the Royal Canadian Mounted Police, and the Penobscot and Piscataquis County Sheriff’s Departments assisted in the investigation.

It was not immediately clear if or how Marshall knew either Gray or Elliott, or if the three men had any connection with one another.

“We will try to establish what is the link between these three men, but as of tonight there’s no known connection,” McCausland said.

The Associated Press contributed to this report.