Melissa Reid, of Lenzie in East Dunbartonshire, learned her fate alongside co-accused Michaella McCollum, of Dungannon, County Tyrone, at a court in Lima last night.
Both had previously admitted their guilt, but had feared they would have to serve jail terms of up 15 years if they did not provide information to the Peruvian authorities on the "handlers" who set up the drug smuggling operation.
However, their lawyer said they had received the minimum sentence for smuggling the cocaine, which was said to be worth £1.5 million, after striking a behind-closed-doors plea bargain to secure a shorter sentence.
It is possible Miss Reid could serve some of her sentence in the UK. The women's lawyer, Meyer Fishman, said they would not appeal the court's sentence.
Both young women, who had been working on the Spanish party island of Ibiza this summer, were caught with 11kg (24lb) of the drug hidden inside packages of food in their luggage when they were stopped and searched at Lima's international airport.
They were arrested while waiting to board a flight to Madrid and then on to Majorca, and claimed they were coerced into carrying the drugs by Colombian criminals who kidnapped them at gunpoint.
Sentencing on both Miss Reid and Miss McCollum had been delayed after they admitted the offences in September because prosecutors were not satisfied with the details of their confessions.
The families of both women have visited them in prison in recent weeks, while excerpts of Melissa Reid's diary were leaked to the media in the UK.
In it, the Scot claims she and McCollum were kept in the back of a prison van in intolerable heat for a day without food, water or access to a toilet following their arrest.
She also wrote of her fears of receiving a long sentence, saying: "I have prepared myself for the worst. I think of how I will be in 15 years. And, yes, it does still scare me.
"I would really like to have this over with by Christmas because the fear of the unknown makes me more anxious. I've been waiting four months already and the delays and changes are annoying.
"All this time the idea was I would be sentenced to six years eight months but then serve one-third of that if I worked or studied [in prison] - so roughly two years three months - but now I will have to serve the full sentence."
The diary also reveals Reid is afraid she will be separated from McCollum.
Both arrived together at court, looking healthy despite having already spent almost four months in the notorious Virgen de Fatima prison in Lima.
Waiting TV crews filmed them as they were taken into the courthouse by armed military-style guards, and Miss McCollum was snapped holding a self-help book entitled 'Secrets About Life Every Woman Should Know'.
The pair were sentenced by Judge Pedro Miguel Puente Bardales in what was described as a "brief process".
Judicial spokesman Daniel Vega said: "The women were very calm as the sentence was handed down at the court in the Sarita Colonia prison. They will now begin serving their sentence in the Santa Monica prison. It is still not clear whether they will be able to serve part of their sentence in the UK - the judge said that was not a decision for the court and they would have to reach an agreement with the prosecution."
Santa Monica women's prison sits on the outskirts of Lima and is said to be dangerously overcrowded.
Both women will require financial support as inmates can use money to make their sentences easier by buying extra food, mobile phones and limited luxuries such as soap, clothes and toothpaste.
A 2012 United States Department of State report said that the prison had 1,035 inmates, more than double the 450 it was designed for.
The UN has recently declared that Peru has now overtaken Colombia as the world's number one coca leaf producer, the raw material of cocaine.
According to a report by the United Nations Office on Drugs and Crime, coca plantations in Peru covered 60,400 hectares last year.
Peru's national prisons institute says that 90% of the 1,648 foreigners in the country's prisons are either sentenced or awaiting trial for drug trafficking.