ROME – Italy's Parliament on Monday passed a measure on Web advertising, the so-called Google tax, which will require Italian companies to purchase their Internet ads from locally registered companies that pay taxes on them, instead of using firms based in such havens as Ireland, Luxembourg and ­Bermuda.

The tax has stirred ­controversy, with some lawyers saying it violates European Union laws regarding nondiscrimination over ­commercial activity.

In July, at the request of the Group of 20 nations, the Organization for Economic Co­operation and Development (OECD) proposed a blueprint to fight strategies used by such companies as Google, Apple and Yahoo to shift taxable profits into havens. Italy now becomes the first major European ­government to pass legislation to combat the problem of moving corporate taxable earnings into havens, which costs Europe and the United States over $100 billion a year.

Italy's measure is "fairly obviously contrary to E.U. law," said Sol Picciotto, an emeritus professor of law at Lancaster University in Britain. Still, he said the law "will put further pressure on the OECD to sort it out." The OECD isn't scheduled to complete its plan until the end of 2015.

Google, Starbucks and Amazon.com have been ­criticized for strategies that shift billions of dollars of profits offshore. Google, for example, sells nearly all its advertising in Europe from an Irish unit, leaving little taxable profits in the countries where its customers are based. That unit in turn pays royalties to a second Google subsidiary, which says its headquarters are in Bermuda.

Google last year moved nearly $12 billion to the Bermuda unit, the majority of its worldwide income, ­cutting more than $2 billion off its global income tax bill. Google's Italian unit last year reported total income taxes of less than $2.5 million, ­corporate filings show.

Italy's new law is "the wrong answer to the right problem," said Carlo Alberto Carnevale-Maffe, a professor of strategy at Bocconi University's School of Management in Milan. "It's driven by finding excuses for the Italian ­government's fiscal laziness and fiscal profligacy, and needing new tax revenues. And the second thing is to protect the interest of ­traditional publishers."

An earlier version of the Italian measure also applied to goods purchased online. It was scaled back after Matteo Renzi, the new leader of Prime Minister Enrico Letta's Democratic Party, said it should be scrapped.

The law will require advertisers to purchase Web ads from an Italian company, rather than from one in a more tax-favorable jurisdiction. This restriction could run afoul of E.U. laws giving European companies freedom to buy and sell across borders regardless of where the corporation is established.

"At first glance, we would have doubts about the amendment as it now stands, as it appears to go against the ­fundamental freedoms and principles of nondiscrimination," said Emer Traynor, a spokeswoman for the European Commission on tax issues. "We'd encourage the Italian government to ensure that any new legislative measures they adopt are fully compatible with E.U. law."

Letta said on Friday that his government will coordinate with the European Union on the Italian tax measure.