TOKYO — Tama the stationmaster, Japan’s feline star of a struggling local railway, was mourned by company officials and fans and elevated into a goddess at a funeral Sunday.

The calico cat was appointed stationmaster at the Kishi station in western Japan in 2007. Donning her custom-made stationmaster’s cap, Tama quietly sat at the ticket gate welcoming and seeing off passengers. The cat quickly attracted tourists and became world-famous, contributing to the railway company and local economy.

Tama, who had turned 16 in April, died of a heart failure on June 22. During Sunday’s Shinto-style funeral at the station where she served, Tama became a goddess. The Shinto religion, indigenous to Japan and practiced by many Japanese, has a variety of gods including animals.

In one of several portraits decorating the altar, Tama posed in a stationmaster’s hat and a dark blue cape. Sake, as well as watermelon, apples, cabbage and other fruits and vegetables were presented to the cat. A stand outside the station was heaped with bouquets, canned tuna and other gifts left by thousands of Tama fans who came to pray from around the country.

Wakayama Electric Railway President Mitsunobu Kojima thanked the cat for her achievement, and said Tama will be enshrined at a nearby cat shrine in August.

Before Tama’s arrival, the local Kishigawa Line was near-bankrupt; and the station was unmanned as it had lost its last staff.

Kojima said appointing Tama as stationmaster was initially an excuse to keep the cat at the station.

“But she was really doing her job,” he said. The rest was a miracle, and his company’s success story also gave hope for dozens of other struggling tiny local train lines, he said.

“Tama-chan really emerged like a savior, a goddess. It was truly my honor to have been able to work with her,” Kojima said in his speech.

During her tenure, Tama had contributed an estimated $8.9 million to the local economy, Kojima said.