According to federal prosecutors, the 30-year-old has not shown remorse and has attempted to radicalise others in prison to support Islamic State.
Rahimi, known to many as the "Chelsea bomber", was convicted in 2017 October on all eight counts brought against him in court, including the use of a weapon of mass destruction and bombing a public place.
New York Governor Andrew Cuomo said in a statement "justice has been served".
"The sentencing will not heal the pain and suffering that this despicable act caused New Yorkers, but it sends a strong message that we will not tolerate those who seek to sow fear, hate and violence."
On the morning of 17 September 2016, Rahimi left his home in Elizabeth, New Jersey with several homemade bombs.
The first bombing location he chose was along the route of a Marine Corps charity race in Seaside Heights, New Jersey.
Who is Ahmad Khan Rahimi?
Due to a last-minute change to the race schedule, no people were injured when that pipe bomb detonated. Investigators said Rahimi then planted two bombs in the Chelsea neighbourhood of New York but one failed to detonate.
Other remaining devices were left in a discarded rucksack in a rubbish bin at a train station in New Jersey on the day after the weekend attack.
The trial in October heard that Rahimi's fingerprints and DNA were discovered on both bombs laid in New York City. Jurors also saw CCTV footage of the suspect walking the Manhattan streets to where the bombs were placed.
Rahimi was arrested two days after the attacks following a shootout with police in New Jersey, which left him in hospital for weeks.
More about: New-York-bombing