Karen Freeman-Wilson knows her city is in trouble.

About a third of people in Gary, Ind., live in poverty. A fifth of buildings are vacant or abandoned. Potholes and trash mar the streets — the budget has little room for regular upkeep.

So, Freeman-Wilson, who grew up here and became the city’s first female mayor five years ago, penned an open letter to a man she believes could help revive Gary: Jeffrey P. Bezos, chief executive of Amazon.com.

Bezos had recently announced he was looking for a place to open the technology giant’s second headquarters — a move the company says would bring up to 50,000 jobs that pay an average annual salary of $100,000.

Freeman-Wilson thought: Why not Gary?

She appealed to Bezos in the voice of her city, spending nearly $10,000 to publish the words as an advertisement this week in the New York Times.

“I know locating to me may seem far-fetched,” she wrote. “But far-fetched is what we do in America. It was far-fetched for 13 scrawny American colonies to succeed against the might of the British Empire.”

Amazon, based in Seattle, says it plans to pour $5 billion into building and running the new location, to be named Amazon HQ2.

“We expect HQ2 to be a full equal to our Seattle headquarters,” Bezos said in a statement. “Amazon HQ2 will bring billions of dollars in up-front and ongoing investments, and tens of thousands of high-paying jobs.” (Bezos also owns The Washington Post.)

The company is collecting proposals from government leaders — Chicago, Boston, Austin and New York City are already lining up — and says it wants to break ground in an area with a university, more than 1 million people and easy access to an international airport.

Freeman-Wilson argued Gary has all these things. The city’s population is about 76,000, but it’s 30 miles from Chicago, she said, and is close to Indiana University and Purdue University commuter campuses.

“But the best part of me are my people — resilient, eager to work,” she wrote.

Four decades ago, Gary flourished as a steel town.

U.S. Steel employed about 30,000 residents. Practically anyone who wanted a job could find one, Freeman-Wilson said. Gary had neatly painted houses with sturdy fences and healthy lawns. The city was full of young families (including Michael Jackson's).

Then came automation and foreign competition. The steel mill gradually slashed its workforce to about 3,000. The population shrank by 100,000.

One robot could do the work of 10 men, a former steelworker at the Gary plant recently told the Guardian. And some buyers turned to cheaper Chinese steel.

“People are leaving,” Freeman-Wilson told The Post of Gary’s decline. “You have an increase in crime, because people can’t find jobs and revert to bad ideas. You can’t fix the buildings because you don’t have the tax base, and the city crumbles.”

The city has had to dismiss about three-quarters of its maintenance workers, she said, because it can’t afford to pay them.

Still, she doesn’t blame trade or neglectful politicians for what happened to Gary. Though President Trump largely claimed the Rust Belt during the election, the city in a red state stayed reliably blue.

“You know what happens when you put all your eggs in one basket,” Freeman-Wilson wrote in her letter to Bezos. “I rode the big wave during the industrial revolution but I took a big fall once that wave ended.”

Her strategy now is not to just win Amazon’s business. The city is also working to attract more manufacturing and logistics firms. Indiana’s unemployment rate sits at a tight 3.6 percent, below the national rate, but Gary’s is at 6 percent — meaning: There’s more workers available for jobs. A trucking company, she said, just broke ground for its headquarters in Gary.

Amazon would be a big prize. Gary is working with state and regional economic development experts on an offer that will include tax credits and other discounts. (Indianapolis is also competing, and the proposals are due next month.)

“We have been through challenges and bottomed out,” she said, “and now we are rebuilding.”