A Massachusetts man agreed Tuesday to plead guilty to two federal charges related to an alleged plot to attack the US Capitol building and the Pentagon with large remote-controlled model aircraft packed with explosives.

Rezwan Ferdaus of Ashland, Mass., will serve a 17-year prison sentence and 10 years of supervised release if the agreement is accepted by a federal judge in Boston.

The defendant agreed to plead guilty to attempting to use explosives to destroy a federal building and attempting to provide material support to terrorists.

Mr. Ferdaus, a physics graduate of Northeastern University in Boston, was arrested in September shortly after undercover FBI agents posing as Al Qaeda operatives delivered 25 pounds of sham C-4 military explosives, three grenades, and six AK-47 assault rifles to a storage locker.

Ferdaus came under scrutiny by the FBI when an unnamed cooperating witness tipped off authorities. The cooperating witness had been in contact with Ferdaus from December 2010 to April 2011.

Undercover FBI agents entered the investigation in March 2011.

“Ferdaus told the [undercover agents] that he realized more than a year ago from viewing jihadi websites and videos ‘how evil’ America is, and that jihad is the solution,” according to documents on file in federal court.

The documents say Ferdaus wanted to “terrorize” the country and “decapitate” the US government’s military center. He told the agents he hoped to “severely disrupt … the head and heart of the snake.”

His drive to attack the US was so strong, documents say, that at one point he told the undercover agents: “I just can’t stop; there is no other choice for me.”

Federal authorities say Ferdaus also provided the agents with 12 mobile phones that had been altered to function as detonation switches for improvised explosive devices. Calling the phone number would trigger the explosion.

The undercover agents told Ferdaus that his phone switches were being sent to Iraq for use against US forces. At one point they told him (falsely) that his phone device had been used in an IED that killed three American soldiers and injured four or five others.

“Ferdaus was visibly excited by this news and told the [undercover agents] he felt ‘incredible … we’re changing the world,’ ” according to federal documents.

He allegedly told the agents he was 100 percent at peace with the fact that his devices were being used to kill American service members.

“This is exactly what I wanted and I feel so blessed.… I feel that I am seeing the fruits of my labor.… I want to work with you guys and I want to hit the snake on the tail and I want to choke it right in the head.… The world will never be the same,” he is quoted as saying.

His idea to attack buildings in Washington included a plan to obtain model aircraft capable of flying up to 100 miles per hour and carrying a payload of 50 pounds. His first design was to load each plane with 16 grenades timed to detonate immediately prior to contact. Later he asked the undercover agents to see if they could locate plastic explosives.

His plan was to fly one plane into the center of the dome of the Capitol and cause it to collapse. The Pentagon was to be hit by two planes directed into the building’s fourth floor.

Both attacks would include gunman positioned near building exits to shoot anyone trying to escape.

Federal officials stress that the public was never in danger from the explosive devices and that Ferdaus was under surveillance as his plot developed.

A sentencing date has not yet been set.