Foreign Minister Luis Videgaray said such a tax would make Mexican imports more expensive for US consumers and they would end up paying for the wall.
The Mexican president earlier cancelled a visit to the US over the row of who would pay for the barrier.
The planned wall was one of Mr Trump’s key election campaign pledges.
Earlier this week, the president signed an executive order to create a wall along the 2,000-mile (3,200km) US-Mexico border.
Speaking on Thursday, Mr Videgaray said: “A tax on Mexican imports to the United States is not a way to make Mexico pay for the wall, but to a way make the North American consumer pay for it through more expensive avocados, washing machines, televisions.”
He also stressed that paying for Mr Trump’s wall “is not negotiable” for Mexico.
Earlier on Thursday, White House spokesman Sean Spicer said a 20% tax could generate approximately $10bn (£8bn) in tax revenue per year.
“Right now our country’s policy is to tax exports and let imports flow freely in, which is ridiculous”, he said, adding that the tax will “easily pay for the wall”.
But Reince Priebus, the White House chief of staff, later said that the border tax is only one of several options being considered.
President Enrique Pena Nieto would have been perceived as very weak if he had travelled to Washington for talks and for many here it would have been tantamount to accepting Mr Trump’s central claim – that Mexico will pay for the US border wall.
If that is not up front, then it may come eventually – perhaps under the latest proposal being floated by Donald Trump’s White House, a massive 20% border tax on Mexican imports.
As Mexico exports some $300bn of goods a year to the US, the impact of such a proposal would be felt across the country.
Furthermore, the idea of funding a wall through a new tariff is simply unacceptable to most ordinary Mexicans who view the wall as unnecessary, inhumane, expensive and ineffective.
As their elected leader, at least for the next 18 months, Enrique Pena Nieto was left with little option but to deliver that message to the White House – by not going there in person.
The rift between the neighbours and trade partners has deepened just days into Mr Trump’s presidency.
After Mexican President Enrique Pena Nieto pulled out of next week’s summit, Mr Trump said the meeting would have been “fruitless” if Mexico didn’t treat the US “with respect” and pay for the wall.