The measure is part of a vast fiscal reform pushed by President Enrique Pena Nieto to boost the country's dismal tax revenues.
The Senate voted 72-2 to impose an eight percent tax on foods with at least 275 kilocalories per 100 grams, such as snacks, flan, peanut butter and ice cream.
The conservative opposition was absent during the voting after walking out over its rejection of another reform measure, a sales tax hike for states bordering the United States.
Since the proposed junk-food tax is higher than the five percent levy that was approved by the chamber of deputies this month, the measure will go back to the lower house for a new vote.
Backers of the bill say it will help combat obesity and diabetes in a country where more than two-thirds of the population is either overweight or obese.
But critics say the underlying goal is to raise revenue for a government with a dismal tax intake amounting to 13.7 percent of gross domestic product, compared to 18.4 percent in the rest of Latin America.
"You don't fight obesity with taxes that mainly affect the poorest ... and put jobs and investments at risk," said a newspaper advertisement bought by restaurants and sugar producers.
The tax is opposed by ConMexico, a food and drinks industry association that represents major foreign companies such as Coca-Cola, Kellogg's, Danone and Nestle.
Mexico now has a higher rate of overweight people than the United States and it also has the highest prevalence of diabetes among the 34-nation Organisation for Economic Co-operation and Development.
The Senate is also debating a special levy on sugary drinks of two pesos (8 US cents) per liter which was approved by the lower house despite intense lobbying from soda makers.
Mexicans are the world's biggest consumers of fizzy beverages at 163 liters (43 gallons) per capita per year.
The Senate began a marathon debate on Pena Nieto's fiscal reform on Tuesday. After approving the legislation's general outlines, it started a heated discussion on its details.
Early Wednesday, the senators voted 68-55 to increase the sales tax in the border region from 11 percent to 16 percent, on par with the rest of the country.
The measure was backed by Pena Nieto's centrist Institutional Revolutionary Party, its Green allies and some members of the leftist Democratic Revolutionary Party.
But the conservative National Action Party warned that it would hurt border cities, making them less competitive next to the powerful US economy.
Thousands of workers protested against the tax increase in Ciudad Juarez last week. The city, which is recovering from years of drug violence, is a hub for "maquiladoras," or assembly plants that make everything from televisions to auto parts.