LAST year Don Dean, a logistics expert, set out to solve a mystery: why were oil and mining firms in Alberta buying heavy equipment from Asia, landing it in United States ports and bringing it in by motorway rather than using suppliers in Ontario? The answer, he discovered, is bureaucracy. Lorries carrying heavy loads in Canada need permits from each provincial government, municipality and utility company along the route. Ontario can take 27 weeks to issue one, says Mr Dean, who works for Prolog Canada, a consultancy. The journey on American roads requires just one licence.

Canada’s constitution of 1867 mandates the free flow of commerce across the country. But leaders of the ten provinces and three territories have spent 149 years inventing creative ways to favour local firms or issuing regulations that unintentionally snarl trade through sheer complexity. Some are mere nuisances: lambs’ heads are thrown out by federally licensed slaughterhouses but given back to the farmer for sale in some provinces (they are a delicacy in some cultures). Other impediments loom larger. Canada lacks a single securities regulator; production of milk must be matched to local consumption; the sale of alcohol is reserved for provincial monopolies. Twelve regional regulators license engineers. Canada’s internal market for goods and services is less integrated than that of the EU, concluded Alicia Hinarejos, of the University of Cambridge, in a study in 2012.

No one knows how much this costs in lower productivity from lost economies of scale. In a recent report, “Tear Down These Walls”, the Senate’s banking committee guessed that the economy loses C$130 billion ($99 billion) a year from internal barriers, which is among the higher estimates. A more reliable answer will come later this year when EY, an accounting and consulting firm, completes work on an index of barriers and their costs that was commissioned by the federal government in 2014.

Internal obstacles are one reason that provinces trade more with foreign countries than with each other; another is the American market next door (see chart). Earlier attempts to dismantle barriers have been half-hearted. An Agreement on Internal Trade reached in 1994 eliminated specific obstacles but did not sweep most away. Provinces often ignored it. Quebec protected its dairy farmers by insisting that margarine could not be the same colour as butter; Alberta, which makes butter-coloured spread from canola, protested for years (before winning its case). Fines of up to C$5m, introduced in 2009, improved compliance. The agreement has been extended to cover some aspects of labour mobility, but large gaps remain. Unlike the EU, Canada has left the demolition of internal trade barriers to politicians rather than the courts. Canada’s Supreme Court, reluctant to interfere in provincial affairs, has ruled narrowly in trade cases on whether a province was acting within its constitutional powers rather than on broader issues of internal free trade. That has spared Canada EU-style complaints about rules on banana curvature imposed from afar by bureaucrats. But it has also allowed the national market to remain a patchwork. The federal government, which has jurisdiction over inter-provincial commerce, has sermonised on freer trade but not enforced it. Two recent events have changed the mood. The first is the conclusion in February of negotiations on a free-trade agreement between Canada and the EU (CETA). Under the proposed deal, Canada would offer European firms broader access (for example, in public procurement) than provinces give to each other’s companies. This showed that Canada’s internal obstacles are “a bit ridiculous”, said Tom Marshall, a former premier of Newfoundland and Labrador. After Britain’s vote to leave the EU, CETA is likely to fall apart, but its shaming effect lingers. A bigger spur to reform is a decision by a court in New Brunswick in April to dismiss charges against a man who bought cheap beer and spirits in neighbouring Quebec to guzzle at home. The judge took a more expansive view of his powers than earlier precedent-setters have done. “The fathers of confederation wanted to implement free trade as between the provinces of the newly formed Canada,” he wrote. New Brunswick’s liquor laws thus violate the constitution. The province has appealed; the case may reach the Supreme Court.

Before that happens the provinces may take action. On July 8th their trade ministers decided to revise the internal-trade agreement. The “positive list” of deregulated sectors will be replaced by a “negative list”, a limited number of sectors exempt from free trade. A new mechanism will be created to harmonise provincial regulations. Provinces are to offer each other the same access Canada does to countries with which it has trade deals. Brad Duguid, Ontario’s minister responsible for trade, calls the agreement “unprecedented”. As The Economist went to press, provincial premiers were expected to ratify it.

Yet resistance to the Canadian single market remains strong. Alberta lobbied to reserve for local firms a big share of contracts to rebuild Fort McMurray, the centre of its oil industry, which was burnt down by wildfires this year. Deregulation of trade in liquor, dairy products, poultry and eggs has been left until later. Provincial protectionism is not dead yet.