One of Amazon’s antagonists seized the moment last month with an unusual newspaper advertisement addressed to President Trump. The ad, from a nonprofit that advocates less government, attacked a Defense Department technology contract that Amazon intends to bid on, calling it a lucrative handout for the company.

A top think tank critic of Amazon’s market power also credited Mr. Trump on Twitter this month for blasting the internet retailer’s relationship with the United States Postal Service. And the head of a leading labor union said more Americans in both parties should speak out, as Mr. Trump has, about Amazon’s harmful effect on jobs.

As Mr. Trump has become Amazon’s basher in chief with his frequent Twitter attacks on the company and its chief executive, Jeff Bezos, the president has also become an unlikely ally for an array of Amazon critics. Most of them — from think tanks to advocates for local businesses — have struggled for years to build any momentum for their arguments, since Washington officials mostly held Amazon up as a beacon of innovation and shoppers saw little to dislike in its prices, selection and convenience.

Now “what Trump is essentially doing is telling the political ecosystem: Here is how you achieve your business ends,” said Blair Levin, a fellow at the Brookings Institution and a former chief of staff for the Federal Communications Commission. “He is signaling: If you want to go after Amazon, go ahead. Load up your guns.”