A Los Angeles judge handed down the sentence after hearing how Lanez had ordered the hip-hop star to "dance" as he shot at her feet several times.
The sentencing follows Lanez's conviction in December for assault with a semi-automatic firearm, discharging a firearm with gross negligence and carrying a loaded, unregistered firearm in a vehicle.
Prosecutors had requested a 13-year sentence, saying Lanez had caused physical and emotional scarring to Megan.
Lanez's lawyers had asked for him to be given probation or three years in prison and mandatory rehab, including for alcohol addiction.
In a protracted sentencing hearing that began on Monday, Judge David Herriford said he had received more than 70 letters on Lanez's behalf, including from his celebrity friends.
One was from musician Iggy Azalea, whom he said had requested a sentence that was "transformational, not life-destroying". Another came from Lanez's young son.
But the judge ordered the Canadian rapper – who has been in jail since his conviction – to serve a decade behind bars.
He said the prosecution had proven two aggravating factors, involving the use of a weapon and a particularly vulnerable victim, but had not proven that the crime involved a high degree of cruelty, viciousness or callousness.
Megan Thee Stallion – whose real name is Megan Pete – had been in a car with Lanez, his bodyguard and her friend Kelsey Harris after a party at Kylie Jenner's luxury home in July 2020.
She and Lanez – whose real name is Daystar Peterson – had developed an intimate relationship in the months before the incident.
Harris, who only learnt of the relationship that night, had a "crush" on Lanez, she told the court, and an argument then erupted in the car, with Megan demanding to be let out of the vehicle.
She said she saw Lanez pointing a gun at her and opening fire "after he said, 'Dance'".
Megan told the court during the trial she felt she had "been turned into some kind of villain" in the wake of the shooting, with the male-dominated rap world frequently seeming to be against her.
She said she had not experienced "a single day of peace" since she was shot in July 2020. "He not only shot me. He made a mockery of my trauma," she said.