Johnny Fox, a nationally known magician, sword swallower and the Maryland Renaissance Festival’s longest-running performer, died Sunday at 64.

Festival President Jules Smith said Mr. Fox died following a battle with liver cancer. Barbara Calvert, a longtime friend, said he passed away peacefully surrounded by loved ones, who gave him a standing ovation.

Mr. Fox wrapped up his last season with the Crownsville-based festival in October after performing there for 37 years. This season, the stage he performed on was renamed the Royal Fox Theatre in his honor.

“During the time Johnny performed with us, over 8 million people passed through our gates. If you talked to most people, they saw his show,” Mr. Smith said. “He was exactly in person as he was on stage.

“Even in the worst parts of his illness, he was always very polite and very kind to people,” he said. “That’s exactly how he’s been since I met him in 1981. He had a tremendous impact on people.”

Mr. Fox was born in Minnesota and raised in Hartford, Conn. Mr. Smith, a friend of 38 years, said Mr. Fox started performing as a teenager in Florida before moving to California to do shows at clubs and prestigious magic institutions.

He said Mr. Fox appeared countless times on television, and performed alongside the likes of Frank Sinatra, Robin Williams and Dolly Parton before joining the Maryland Renaissance Festival.

“The woods in Crownsville was his favorite place in the world,” Mr. Smith said “He loved being able to interact with his audience. It was better than any club or television spot where he would be looking out into the darkness. He knew he could make people happy and he needed to see their faces.”

Working before a live audience or on TV, Mr. Fox made it his mission to introduce families to his world of “circuses, carnivals, sideshows and the life of people involved in them,” said Mr. Smith. Mr. Fox was also gracious in lending a hand to fellow performers, he said.

His haunts also included New York, where he ran an oddity-filled Manhattan museum called Freakatorium for several years. Items on display included a shrunken head, a two-headed turtle and clothing from circus performer Tom Thumb, Mr. Smith said.

Mr. Fox also performed at Coney Island's freak show.

“He was one of the finest examples of a sideshow virtuoso, as well as being a celebrity within our own culture,” Patrick Wall, general manager of the nonprofit Coney Island USA, told the New York Daily News. “We lost one of the best. He had a dynamic stage presence and just a complete love and commitment to what he did.”

“He was very proficient at magic, but people started stealing his bits,” said Mr. Smith. He said Mr. Fox figured it would be harder to steal a sword-swallowing act.

“He started with cooked spaghetti — swallowing, holding the end, pulling it back out,” said Smith. Then “he did a string and a key like Harry Houdini, someone he admired greatly, until he could regulate his gag reflex.”

Then came the swords. There were a few mishaps, but within eight months he'd mastered it.

Mr. Smith said that while some of Mr. Fox’s last performances were without his signature sword swallowing, he kept audiences delighted by telling stories, doing magic tricks and swallowing balloon swords.

Fellow festival performer Michael Rosman, who hosted a fundraiser for Mr. Fox in June, said he and many other festival performers visited Mr. Fox at his home as he grew increasingly ill. They would play and perform for him.

“He lived every moment with appreciation, and he totally saw the beauty in everything,” said Mr. Rosman. “In these last six months, it was all about, ‘Where is the joy in the world and how can I spread it?’ He got to thank the whole world and they got to thank him.”

In August, Mr. Fox toldThe Capital that he relied on diet, alternative medicine and a fiercely optimistic attitude to keep going.

Photographer Larry French captured Mr. Fox’s last performances at the Maryland Renaissance Festival, including a moment of peace he shared with the audience in one of his final shows.

“In the last weekend or two of his show, you could tell he was becoming weaker. He was dropping stuff and nobody moved,” Mr. French said. “Nobody judged. Everybody understood.

“I expected to see him next year,” he added. “I think everyone did, in a hopeful way.”

A celebration of Mr. Fox’s life will be held in Maryland at a future date.

The Associated Press contributed to this article.