Buying a $100 sword at Medieval Times is something most people wouldn’t be inclined to do.

Mac Dolan clearly is not most people.

So, on June 23, when he awoke at 5 a.m. to the sound of a woman screaming inside his Wicker Park apartment, the 44-inch-long, 10-pound sword proved to be a worthy investment.

Dolan, 25, hopped out of bed, flicked on the lights and saw a man he didn’t know punching, choking and trying to rip the clothes off a female guest who’d crashed on his living room couch after a night out.

“I saw the guy standing over her, and she was kicking and screaming,” Dolan told the Chicago Sun-Times. “And I just started yelling and running at the guy basically and grabbed the sword that we have on the wall and chased him toward the back stairs.”

He bought the sword, with its wall mount, about six months ago on a tipsy pilgrimage to celebrate a friend’s birthday at Medieval Times in Schaumburg. For the uninitiated, Medieval Times is a restaurant/theater where dinner is served up with jousting and other knightly theatrics in a space resembling a castle.

The attacker took a moment to register what Dolan was doing.

“He didn’t really start running until he saw me grab the sword,” said Dolan, a software consultant. “Then, he went bug-eyed.

“When I got to the landing at the top of the stairs, I took one cut at him with the sword, but he ducked, and I missed and dented the wood railing.”

The man ran down the stairs. Dolan went back to check on the bruised and rattled woman, call 911 and wake a friend visiting from Boston who’d slept through it all on a couch several feet away.

“While we were waiting for police to arrive, I found the guy’s wallet on the ground,” Dolan said. “It must have fallen out of his pocket. I found a Carolina Panthers hat, too.”

Dolan’s roommate and lifelong friend John Henry Zuercher, 25, who’d left for work half an hour before the attack — figures the intruder had been hiding in their apartment for some time. He heard rustling and noticed their back door was open, but he didn’t see anything when he looked around, so he left.

Around the time the police got there, a man walked in to a nearby Shakespeare District police station in Logan Square and reported he’d been the victim of a robbery, that his wallet was stolen.

Officers ran a search on his name and discovered he was wanted for the attack that Dolan had put a stop to with his $100 Medieval Times sword.

Francisco Chavez, 39, who lives in Logan Square, was charged with home invasion, attempted aggravated criminal sexual assault and aggravated criminal sexual abuse.

Dolan and Zuercher both remember their reaction when they first saw the sword: “We need it!”

“It’s kind of funny because we have pretty frequent conversations about using the sword if someone breaks in,” Dolan said. “We hung it in the wall equidistant between our bedrooms, so whoever gets there first can use it.

“We’re ‘Game of Thrones’ guys,” Zuercher said.

The story of the sword-wielding man spread among officers at the police station at Belmont and Western, where Dolan found himself the toast of the town hours later as he shared details of the confrontation.

“That’s the sword guy,” detectives told each other.

“The cops thought it was awesome,” Dolan said.

It turned out Chavez matched the description of a peeping tom they’d been looking for. Authorities also charged Chavez in that case, which took place June 14 in nearby Noble Square.

A woman told the police she saw a man urinating in the middle of the day in Pulaski Park just north of Division Street and west of the Kennedy Expressway who then followed her for about a block to her apartment and began pacing back and fourth outside her building, according to Assistant Cook County State’s Attorney Ed Murillo.

When a couple of dog walkers asked what the man was doing, he responded: “I’m just waiting for that white bitch next door,” according to Murillo.

Minutes later, the woman saw the man peeping through a window and ran out her back door. Two workmen chased him away.

Minutes later, the dog walkers saw him climb through a bedroom window into the woman’s apartment, Murillo said. The woman heard a noise and found Chavez standing in her closet.

She again ran out of the house screaming. Murillo said Chavez chased and tried to grab her, but the two dog walkers again were passing and chased him down an alley, where he was caught on a surveillance camera.

Witnesses identified Chavez from a photo array after he was arrested, the prosecutor said, and he was charged with residential burglary and criminal trespass in that case and ordered held in jail without bail.

The whole thing left Dolan more convinced than ever that it’s good to have a sword around. So he’s ordered a second one — a Japanese katana. This one cost him $200.