The MTA plans to tear down an elevated walkway that it closed last month near an elementary and middle school in Brentwood, officials said Thursday.

The overpass — which crosses Long Island Rail Road tracks a half-mile from the Brentwood train station — is expected to be demolished by the end of the year, Metropolitan Transportation Authority spokesman Aaron Donovan said.

In September, MTA officials blocked the entrance to the walkway, which leads to the shared campus of the East Kindergarten Center and East Middle School, with chain-link fences, Donovan said.

Suffolk County Legis. Monica Martinez (D-Brentwood) and Brentwood school district Superintendent Levi McIntyre asked the MTA to remove the walkway because it attracted criminal activity, Donovan said.

Students reported they were offered drugs and approached by gang recruiters on their way to school, said Martinez, who served as the middle school’s assistant principal from 2008 to 2013. “Our young girls were solicited sexually,” and many students witnessed fights, she said.

Brentwood students and parents were “elated” when the MTA closed the walkway, Felix Adeyeye, a school district spokesman, said.

advertisement | advertise on newsday

“It has allowed an increased measure of safety,” he said. “Students don’t have to worry about that overpass anymore.”

The walkway was no longer useful because all students are bused to school, officials said.

Students have not reported problems since the walkway’s closure, but officials are “trying to be preventative instead of reactionary,” Martinez said.

The overpass will likely be dismantled by contractors who are already working on LIRR tracks in the area, Donovan said. The two-day demolition, to be funded by the MTA, is expected to cost less than $150,000, and officials may try to lower that cost by selling the structure as scrap metal, he said.

The demolition plan comes after the recent slayings of six people in Brentwood.

Nisa Mickens, 15, was found beaten to death Sept. 16, and the body of Kayla Cuevas, 16, was discovered the next day.

When investigators searched wooded areas after the girls’ slayings, they discovered the remains of Oscar Acosta, 19, Miguel García-Morán, 15, and Jose Peña-Hernandez, 18, on the grounds of the Pilgrim Psychiatric Center.

On Oct. 13, Dewann A.S. Stacks, 34, was fatally assaulted as he walked near a wooded area.

advertisement | advertise on newsday

Suffolk County police have said they believe the killings are related to the MS-13 gang, which has terrorized Brentwood. More than 30 gang members have been arrested since Mickens’ body was found Sept. 16, police said.

Police also plan to install license-plate readers throughout Brentwood to enhance crime-prevention.