After fighting in court to keep his private email accounts completely concealed from public view, Mayor Rahm Emanuel on Wednesday released a trove of messages from throughout his nearly six years in office and announced a new city ban on using private email to conduct official business.

The records released by his administration showed Emanuel has frequently used a private Gmail account and another personal, unofficial email address — mayor_re@rahmemail.com — to communicate with top aides, business leaders, political supporters, national media figures and others who wanted to discuss city government with him.

Emanuel’s reversal followed more than a year of litigation to stonewall Freedom of Information requests filed by the Better Government Association and the Chicago Tribune. The lengthy legal battle was contrary to Emanuel’s campaign promise to shine the light on city government and run a transparent administration.

The end of the BGA’s lawsuit followed two Cook County court rulings against the Emanuel administration, with judges finding the emails of public officials are not exempt from disclosure under the state open records law simply because they are on a private email account.

“This is a major victory in the fight for transparency at City Hall,” said BGA President and CEO Andy Shaw, comparing Emanuel’s actions in evading scrutiny until now to those of Hillary Clinton and other government officials around the country.

Shaw said Emanuel should never have resisted making these private emails public and had forced “a long expensive process to accomplish something that should have been done because it’s the right thing to do.”

The newly released emails show the mayor and his advisers’ reactions in some stressful moments. On the first day of the 2012 teachers’ strike, Frank Clark — now Emanuel’s school board president — wrote to the mayor offering support and advice.

“This unfortunate situation does however provide a window of opportunity to focus the media and the general public in another direction. Namely, toward more charter schools,” Clark wrote on Sept. 10, 2012.

Before he became governor, Bruce Rauner and his wife, Diana, often wrote to Emanuel about education issues. In one email in June 2012, Diana Rauner told Emanuel, “Congratulations on the $ for the web portal. But what are you doing about proposed cuts in [Chicago Public Schools] funding.”

Other emails shed light on some of Emanuel’s owns views of the city. When former high-ranking aide David Spielfogel wrote to the mayor about the new riverwalk in October, calling it “absolutely incredible,” Emanuel answered: “Totally agree changes the city.”

Ken Griffin | Mitch Dudek/Sun-Times

Ken Griffin | Mitch Dudek/Sun-Times

The emails also show the genesis last spring of billionaire Kenneth Griffin’s $12 million donation to improve the lakefront trail, which was announced Wednesday.

“Lakefront bike path is a disaster,” Griffin wrote to the mayor in April. “How can this be after they just refinished much of the path?”

Griffin went on to ask, “What can we do to repair the lakefront bike path? Can they accept private funding … this is a mess.”

Emanuel replied, “We can do a lot with you.”

Top executives for ride-hailing service Uber and short-term rental website Airbnb both had a direct line to Emanuel as those companies lobbied the city over regulations that could profoundly affect their bottom lines, according to the once-private emails.

David Plouffe, who worked alongside Emanuel in President Barack Obama’s administration, became a board member and executive at Uber — a company in which Emanuel’s brother Ari is an investor.

David Plouffe | Rich Hein/Sun-Times

David Plouffe | Rich Hein/Sun-Times

In November 2015, as the mayor visited China, Plouffe wrote a note to complain that the City Council was weighing regulations that would impact Uber drivers’ ability to make pickups at city airports.

“Assume both of us thought the airport issue was settled and we would never had to discuss again, but unfortunately two significant new hurdles were introduced,” Plouffe wrote. “Coming to you because of their severity that would prevent us from operating. We were all set to announce Monday we were starting pickups.”

Emanuel forwarded the message to underlings. Two weeks later, in time for the Thanksgiving travel rush, Uber and its competitors were free to make pickups at Chicago’s airports.

Ray LaHood, the former federal transportation secretary, also wrote to Emanuel as a member of the Uber advisory board. He asked Emanuel to review an article the company asked him to submit to a newspaper.

“Obviously, I don’t want to say or do anything to hurt or jeopardize you and you efforts,” LaHood wrote.

After the release of the dashcam video of police shooting 17-year-old Laquan McDonald a year ago, Ald. Joe Moore (49th) wrote to the mayor praising his administration’s “meaningful progress” toward greater police accountability.

“It’s been a rough few days watching the media kick the s–t out of you, especially when I know the cover-up narrative is completely untrue,” Moore wrote.

“OK thanks,” Emanuel replied.

Tom Ricketts | AP file photo

Tom Ricketts | AP file photo

On a lighter note, Emanuel wrote to Cubs owner Tom Ricketts in the fall of 2015, saying, “Congrats to you all on Kris Bryant being named [National League] Rookie of the Year.”

Ricketts responded: “Thanks. Now we need Jake [Arrieta] to bring in the Cy Young” award — which he soon did win.

Many of the messages involve Emanuel’s obsession with keeping tabs on media coverage of him.

After subpoenas hit the Chicago Public Schools in April 2015, in the investigation that led to the federal corruption conviction of schools chief Barbara Byrd-Bennett, Emanuel asked aide Lisa Schrader, “Is it dominant story?”

Schrader didn’t sugarcoat the situation: “It’s dominating.”

Emanuel often used his private email accounts to pitch stories to journalists at the New York Times and to New Yorker magazine editor David Remnick.

Others, such as the Washington Post, contacted Emanuel at his private email addresses to seek his input. In October 2015, after the mayor announced city funding for gun buy-back events, CNN’s Wolf Blitzer asked Emanuel to grant an interview.

“How are you doing?” Blitzer wrote. “It’s been too long. Love to the family.”

The mayor’s spokesman, Adam Collins, said more than three-quarters of the messages released Wednesday were incoming emails.

The new city policy prohibits employees from “using their private or other non-city email accounts for the transaction of public business.” If they receive an email pertaining to city business on a non-city account, the email must be promptly forwarded to the city email account.

“I’m pleased that we were able to come to a reasonable agreement with the Better Government Association today to ensure that transparency keeps up with technology and the realities of modern communication,” Emanuel said in a statement. “The new standard we have set clarifies questions not just for me, but for all of Chicago’s 30,000 employees.”

Contributing: Mick Dumke, Bob Herguth