WATERTOWN, Mass. — Thousands of firefighters from across the United States lined the streets of a Boston suburb on Wednesday to grieve for one of two firefighters who died battling a blaze in a downtown apartment building.

In front of St. Patrick’s Church in Watertown, where the funeral was held for Boston Fire Department Lt. Edward Walsh, a gigantic American flag hung from two ladder trucks assigned to local fire companies.

Walsh, 43, and firefighter Michael Kennedy, 33, died on March 26 while fighting a fire in a four-story apartment house in Boston’s historic Back Bay neighborhood.

Seventeen firefighters were injured from among some 150 who went to the scene. None of the tenants was hurt.

Two busloads of Maine firefighters were in Boston for Wednesday’s funeral Mass for Walsh.

Some Maine firefighters planned to stay for Thursday’s funeral for firefighter Michael Kennedy, and others plan to return on Thursday’s buses. A bus met Bangor-area firefighters at Dysart’s Truck Stop at 1:45 a.m. and picked up more firefighters along the way, including some from Augusta, Bath, Brunswick and Portland. Dysart’s donated food to the group, and the buses were chartered by Professional Firefighters of Maine and International Association of Fire Fighters 772.

Maine Gov. Paul LePage ordered the lowering of state of Maine flags on all public buildings and grounds to half-staff from sunrise to sunset Thursday, April 3, in honor of the two Boston firefighters who died.

“On behalf of all Mainers, our heartfelt prayers and condolences go out the families of Lieutenant Walsh and Firefighter Kennedy, as well as their fellow firefighters on the Boston Fire Department,” said LePage.

Bagpiper Brian Young of Scarborough and other members of the Maine Public Safety Pipe and Drum Corps joined about 400 other bagpipers and drummers from across the country and around the world to lead the funeral procession to St. Patrick’s Church. They played “The Minstrel Boy,” “Scotland the Brave” and “Amazing Grace” before the service, Young said Wednesday afternoon as the group’s bus returned to Maine.

Throughout the procession, the Boston Fire Department honor guard held on to the truck carrying Walsh’s body.

“It was incredible to see the support and brotherhood of the firefighters, and of Boston,” Young said.

Firefighters from New York, Chicago and Miami joined the procession ahead of the funeral.

Brendan Gurry, a firefighter from Newark, N.J., said he and about nine others from his department had traveled 300 miles to attend the funeral.

“I would travel as far as my money would take me to show respect for someone who gave the ultimate sacrifice,” said Gurry, 32, who was born in Cambridge, Mass., just outside Boston. “It’s an honor thing.”

As bagpipes played dolefully, a firetruck carried Walsh’s casket, draped in a Boston Fire Department flag, to and from the church. A line of uniformed firefighters, including one with a white bandage around much of his head, saluted as the body was carried into the church.

“This is what it’s all about,” said Bill Shute, retired chief of the Amesbury (Mass.) Fire Department, as he looked at the firefighters gathered outside the church and lining the nearby streets. “We all live this every day. The good and the bad.”

Boston Mayor Martin Walsh and the city’s Roman Catholic archbishop, Sean O’Malley, joined other officials in addressing mourners inside the packed church.

“The entire community of firefighters who are present here today knew him as a leader, as a friend and as a brother,” the mayor said. “As a brave and experienced firefighter, Ed Walsh was a rock supporting all of our lives, whether we knew him or not.”

Aaron Dushku, 40, a Watertown councilor-at-large, said the turnout reflected how well Walsh was known in the community.

“It’s just recognition of a local son, a native son, a brave hero who died in the line of duty,” said Dushku, who attended high school with Walsh. “We’re a pretty tight community.”

Edward Walsh, who is survived by his wife and three children, will be buried next to his firefighter father.

Kennedy’s funeral is due to be held Thursday at Holy Name Church in Boston’s West Roxbury neighborhood.

BDN writer Beth Brogan contributed to this report.