Calling it a crime that “should not happen in civilized society,” a Montgomery County judge sentenced 18-year-old Tavares Harris to 20 years in prison Friday for instigating a shooting at the Rockville Metro station last year that sent midday commuters diving for cover.

Harris brought a .40-caliber handgun to the station and gave it to Kevin Nguyen, who shot their target, a 16-year-old acquaintance, four times. The victim survived. A bystander was wounded when a stray bullet hit her in the buttocks.

The judge, Mary Beth McCormick, said Harris was as culpable as Nguyen. She cited Harris’s infatuation with guns, documented by rap videos that he and his friends made that show him waving a gun. Images from the videos were played at his trial.

“Unfortunately for you,” McCormick said, “you were dumb enough to put it out on the airwaves, on the Internet, so that all the world could see the very gun that was used in this event.”

The case drew attention last year because of its toxic mix of teenagers involved in what seemed to be a petty beef that, over the course of nearly 24 hours, escalated to a planned attack at the Metro station, according to authorities. McCormick had earlier sentenced Nguyen, 17, to 25 years.

“This country cannot tolerate this activity and this violence,” she said Friday. “The message has to be clear, and the punishment has to be significant.”

Moments earlier, Harris had addressed the court and apologized to the people he hurt. He was limited in what he could say, according to his attorneys, because he still has criminal matters pending.

Having been in jail for more than a year, Harris indicated a different attitude to making rap videos evoking violence.

“I have thought about what happened at the Metro every day,” Harris said. “It’s been embarrassing to see the videos of me played in the courtroom. It seemed fun and cool at the time. It seems very stupid now.”

His attorneys, David Martella and Barry Helfand, had urged a shorter sentence — between five and 10 years.

“A 10-year sentence would have been harsh and devastating and punitive,” Martella said after the hearing, noting his client will be exposed to gangs in prison. “I don’ t think there’s any additional benefit to making this very, very young man serve another 10 years.”

Under Maryland rules, Harris will have to serve at least half of his 20-year sentence before he is eligible for parole.

Prosecutors Patrick Mays and Marybeth Ayres had sought a sentence of 45 years.

“In the defendant’s raps,” they wrote to the court, “he glorifies a friend he claims to have who killed a man and is now in prison for 25-100 years. . . . The defendant’s actions, taken as a whole, establish a dangerous obsession with guns and gun violence and an utter disregard for human life.”