The revelation was the second time this year - and the fourth time since 2013 - that the FBI acknowledged that it had investigated someone who later carried out what officials called an act of terror.
Investigators are still trying to determine a motive in the attacks and whether there was any outside help. Since his capture in Linden, New Jersey, signs have emerged that Rahami was interested in extremist ideologies.
An item described as a handwritten journal was found on Rahami after the shootout, according to the complaint filed in Manhattan. Included in the journal was a reference to Anwar al-Awlaki, an American-born cleric who was a top leader for al-Qaida in Yemen, said the complaint, filed Tuesday night in the US District Court for the Southern District of New York. Another was filed in the US District Court for the District of New Jersey.
The journal included notes that said that the FBI was looking for him and that he was praying to Allah "to not take JIHAD away." This journal appeared to be damaged during the exchange of gunfire, the complaint said; law enforcement officials said it had blood on it.
In addition, the journal included references to the Boston Marathon bombings, the 2009 Fort Hood shooting in Texas and "Brother Osama Bin Laden." The papers did not apparently include any reference to the Islamic State, which asserted responsibility for mall stabbings over the weekend in Minnesota but has made no similar claim about the bombing.
A day after Rahami was captured by police, investigators continued to delve into his life and examined his friends, family, records, social-media accounts and phones.
According to friends and court records, many aspects of Rahami's life appeared to begin unraveling after he graduated from high school. As a high school senior in 2007, he got his girlfriend Maria pregnant, and she "was very pregnant" by the senior prom, said Chris Konya, a high school classmate from New Jersey.
Rahami's father was angry about his dating her because she was Dominican and from a different race, said three people who knew him at the time. After graduation, Rahami's father forced him to make a trip back to Afghanistan, even though he didn't want to go, said Imani Podhradsky, a classmate.
After their daughter was born, Rahami and his girlfriend's relationship appeared to be turbulent. Court documents show that she took him to court for not paying child support. On Tuesday, about 24 hours after Rahami was apprehended, she filed an application for full custody, pointing to his involvement in "possible terrorist related activity" and the fact that he was charged with attempting to kill police officers.
In 2014, Rahami was accused of stabbing a family member in the leg, court records show. When Rahami's father spoke briefly to a scrum of reporters Tuesday, he said that the younger man was violent toward other family members "for no reason."
At some point, he married a Pakistani woman. Two years ago, Rahami had been living in Pakistan for a year when he contacted the office of Rep. Albio Sires, D-New Jersey. Rahami said he was having trouble getting his wife an immigrant visa. She was pregnant and able to get her visa only after the baby was born in Pakistan, Sires said.
Sires's office found out that at some point after this, Rahami's wife got her visa, but the congressman doesn't know what happened after.
A Pakistani intelligence officer in Quetta said Tuesday that an initial investigation showed he had visited Quetta, a hub for militant groups, in 2011 and 2013. The intelligence officer said there is evidence Rahami was married there.
According to two federal law enforcement officials, Rahami's wife was overseas when the bombing occurred and heading back to the United States at the time. She was detained in the United Arab Emirates for questioning, officials said.
The references in Rahami's note to bin Laden, Awlaki and attacks like the Boston Marathon bombing and the absence of any mention of the Islamic State raise the possibility he was inspired by al-Qaida, analysts said.
If anything, said Bruce Hoffman, a terrorism expert at Georgetown University, this may be "an al-Qaida-inspired or al-Qaida-linked connection."
Even after Awlaki was killed in a 2011 drone strike in Yemen, his rhetoric continues to resonate online. His teachings have been implicated in numerous terrorist attacks, including the Fort Hood shooting in 2009 and the Boston Marathon bombing in 2013. Authorities say the gunman in Orlando earlier this year and one of the attackers in San Bernardino, Calif., last year had also viewed Awlaki's lectures.
Rahami's travel to Afghanistan and Pakistan between 2011 and 2014 also raises questions about whether Rahami was in some fashion radicalized while he was in South Asia, a possibility investigators are looking into.
Rep. Adam Schiff (California), the ranking Democrat on the House Intelligence Committee, who has been briefed on the New York and New Jersey cases, said the current probe is "reminiscent" of the Boston Marathon case.
In 2013, two brothers planted pressure-cooker bombs packed with shrapnel near the marathon's finish line. Investigators did not initially know whether the brothers - particularly the elder brother, who died in a confrontation with police - had contact with foreign terrorist elements. They were interested in the elder brother's travel, and he had previously come to the attention of the FBI.
"We were looking into whether we had missed something," Schiff said in an interview. "We're asking all those same questions again."
Schiff said that a takeaway from this is that even the best efforts from intelligence agencies and law enforcement "can't always catch people who mean to do us harm."
"I can't say one way or the other" whether the suspect had any contact with or direction from a foreign terrorist group, said U.S. Director of National Intelligence James Clapper Jr. on Tuesday. "I can't point to external direction at this point."
The bombings and the planting of explosive devices in New York and New Jersey are "being investigated as an act of terror," Attorney General Loretta Lynch said Wednesday during a speech in Lexington, Kentucky. She also said that Saturday's stabbing attack in Minnesota, in which 10 people were injured, is being investigated as an act of terrorism.
Earlier this year, Lynch called the shooting rampage in Orlando a terrorist act. The following day, the FBI said it had investigated Omar Mateen, the Orlando, Florida, gunman, for 10 months, ultimately closing the probe in March 2014 after agents determined he was not a threat. In addition to looking into people later linked to the Orlando attack and the Boston Marathon bombing, the FBI had scrutinized one of the gunman who opened fire at an exhibition of cartoons depicting the prophet Muhammad last year.
The gun that was found on Rahami after his shootout was a 9mm Glock he bought in July while in Virginia.
It was not immediately clear why Rahami traveled to Virginia or whether he had ties to the state. Police stopped a car Sunday night in New Jersey they said had been at a location associated with Rahami; an official said Tuesday that two of the five people in the car were from Virginia.