The men, Abid Malhi and Shafqat Hussain, were convicted of gang rape, kidnapping, robbery and terrorism, according to a written order released by the judge in the eastern city of Lahore.
The woman was raped on the side of a highway in the eastern province of Punjab after her car got fuel while driving with her two children in September.
Less than 3% of cases of sexual assault or rape lead to a conviction in Pakistan, according to the group War Against Rape in Karachi.
The two convicted men were also sentenced to life in prison, fined and confiscated property, Rauf Wattoo, a state prosecutor involved in the case, told Reuters.
“The survivor identified the convicts twice during the identification parade in jail and during the recording of her statement before the judge,” said another prosecutor, Waqar Bhatti.
Right-wing fighters have called for an end to the culture that they regularly accuse victims of sexual assault. After the rape in September, one senior police officer publicly asked why the woman was driving alone with her children at night.