As the Cubs made history last fall, the city of Chicago paid overtime — lots of it.

The city spent more than $18.8 million on overtime for public safety, traffic management and street cleanup during the Cubs’ march to their first World Series title in 108 years, according to records released Friday afternoon by City Hall in response to a Freedom of Information Act request filed months ago by the Chicago Sun-Times.

The Series-related tab came as the Chicago police and fire departments together amassed a record $193.5 million in total overtime in 2016. That includes $143 million to the police department alone, an increase of 23 percent from the record total of the year before.

Most of the police overtime stemmed from the department’s response to a 60 percent surge in homicides and shootings in 2016 compared to the previous year. In July alone, the police department paid out $21.6 million in overtime, more than double June spending. As the death toll climbed to levels not seen in two decades, Mayor Rahm Emanuel ended years of retrenchment and proposed a two-year hiring surge that would add 970 officers over and above attrition.

The vast majority of Cubs-related overtime also came in the police department: $17.2 million. The title run also cost the city about $840,000 in overtime for the Office of Emergency Management and Communications and $743,000 for Streets and Sanitation, which provided extra traffic management and garbage collection, records show.

As the Cubs advanced, the overtime costs to the city soared: $14.7 million was spent just on police overtime for the World Series. The celebration parade and rally — which drew throngs estimated in the millions on a picture-perfect November day — cost more than $2.5 million in police and streets and sanitation department overtime.

Molly Poppe, a spokeswoman for the city’s Office of Budget and Management, “There is no reimbursement from the Cubs. This will be paid for by the city.”

Asked why, she said, “This is no different than most sporting events across the country. The teams and/or leagues do not typically pick up these costs.”

Asked about the overtime costs borne by taxpayers, Cubs spokesman Julian Green replied that the team commissioned a study that showed its postseason run generated $37.5 million in direct and indirect spending for the Chicago economy. The figure doesn’t include sales taxes generated as result of that spending, Green said.

The Cubs also paid $6.7 million in city and county amusement taxes in that time, Green said.

The Chicago Sun-Times reported last summer that the Chicago Police Department spent a record $116.1 million on overtime in 2015 — up 17.2 percent from the previous year — to mask a manpower shortage that had mushroomed under Emanuel, with police retirements outpacing hiring by 975 officers.

The new overtime numbers blow the old record away.

“The vast majority of the increase in police overtime spending last year was spent on public safety protections directly related to the Cubs’ postseason run and the World Series rally,” Poppe said. “Those events account for $17.2 million of the CPD increase in overtime last year.”

“Additionally, in 2016, the city used overtime in the police department as one tool to fight crime — just as they did when the city saw historic lows in shootings and murders in 2013 and 2014.”

Several individual police officers were paid nearly $80,000 in overtime in 2016, which the U.S. Justice Department has called a recipe for burnout. Fraternal Order of Police President Dean Angelo agrees, but he acknowledged that there is no shortage of volunteers for the extra work.

“It’s almost an opportunity that people can’t say ‘no’ to. It’s good for your family budget,” Angelo said.

Still, “When you’re going through those types of numbers for overtime, it is a clear example that we don’t have manpower sufficient to handle our daily needs,” he said. “I can see special events. I can see the Wrigley Field detail. The playoffs ran into the World Series and the World Series ran into the parade.

“But, there is also a mechanism in place for record overtime that is a daily practice that has become commonplace. It started when we saw the lack of hiring, and attrition was increasing.”

The Fire Department spent $50.5 million on overtime — 66 percent over its allotted budget for 2016 — with the largest totals going to paramedics.

Retiring Chicago Firefighters Union Local 2 President Tom Ryan has blamed the city’s failure to honor a broken promise to add “at least” five ambulances by July 1, 2016, on a severe shortage of single-role paramedics. “Adding additional ambulances without also adding a sufficient number of single-role paramedics to staff them makes no sense and is unsafe and impractical,” Ryan has said.

Emanuel campaigned for a first term on a promise to hire 1,000 additional police officers, then revised the pledge after taking office by adding 1,000 more “cops on the beat,” more than half of them by disbanding special units. The other half were primarily officers working desk jobs reassigned to street duty.

The mayor also balanced his first budget by eliminating more than 1,400 police vacancies, declaring an end to what he called the annual “shell game” of budgeting for police jobs the city had no intention of filling.

When shootings and murders spiked and Chicago started making national headlines, Emanuel used runaway overtime to tamp down the violence, spending $100.3 million in 2013, $99 million in 2014 and $116.1 million in 2015.

Emanuel and his budget director, Alex Holt, spent years arguing that overtime was a more flexible and cost-effective substitute for police hiring because the city doesn’t have to bear the cost of pensions and benefits for new officers.

In late September, the mayor reversed course. Days before a major policy address on the outbreak of violence, Emanuel unveiled plans to launch a two-year hiring blitz that would fill hundreds of police vacancies and still add 970 police officers.

The hiring surge is the biggest since the mid-1980s.

Over the next two years, the Police Department has promised to add 516 patrol officers, 92 field-training officers, 112 sergeants, 50 lieutenants and 200 detectives. A class of 351 police officers, detectives and sergeants graduated from the police academy earlier this week.