A gunman who slaughtered at least 32 people at a busy tourist site was captured today after he bolted in flames from an inn he had set ablaze with three hostages inside.

The gunman, whom police identified only as a 29-year-old with a history of psychological problems, had opened fire with a semiautomatic rifle Sunday afternoon on tourists at a colonial prison site on the island of Tasmania. It was the deadliest shooting massacre in Australia in this century.

The arrest ended a more than 12-hour stand-off at the guest house, where the gunman had barricaded himself with the cottage's two owners and a man whose car the killer had commandeered. There was no immediate word on the fate of the three hostages, but police indicated they expected to find their bodies inside the guest cottage.

Two Malaysians and an Indian were among those killed at the Port Arthur historic prison complex, one of the most popular tourist sites on the island off the southeastern tip of Australia. Most of the dead were Australians. An infant was slain, as well as two sisters, aged 3 and 6, and their mother. An American and two Canadians were among 19 people wounded. Police did not identify the American but said he was from Washington state and not badly hurt.

The massacre was the latest of several worldwide involving a lone gunman, including the killing of 16 children and their teacher in Dunblane, Scotland, last month. The shooting incident with the highest death toll in the United States took place in October 1991 in Killeen, Tex., when a man killed 23 people in a restaurant. The Tasmanian killings raised the number of deaths from gun massacres in Australia since January 1987 to about 125, according to John Crook, president of Gun Control Australia.

Tasmania has one of the most lax gun laws in Australia. Until the early 1990s, it placed no restrictions on purchases of firearms, including fully automatic machine guns, and mainlanders frequently travel to Tasmania to obtain semiautomatic guns, said Crook. After two mass shootings in Melbourne in 1988, Tasmania began requiring gun licenses, but weapons do not have to be registered.

Witnesses said the man had mingled casually in the crowd at the prison complex before pulling a rifle from a tennis bag and shooting methodically at visitors. The gunman moved on to a nearby pub, shooting and killing more people. He seized a hostage at a gas station and stole a car to drive three miles to a bed-and-breakfast cottage, owned by a couple who apparently were friends of his late father. The Age newspaper of Melbourne identified them as David and Sally Martin.

By early today, more than 200 local and special police units had surrounded the guest house. Police tried to negotiate by phone with the gunman, who fired two heavy caliber military-type rifles at them and at helicopters airlifting out the dead and wounded. He demanded a helicopter for himself.

The top and bottom floors of the cottage were burning when police arrested the gunman outside. "His clothing was on fire, and he started taking his clothing off," said police Superintendent Bob Fielding. Exploding ammunition in the burning house prevented officers from rapidly searching it to learn the fate of the hostages. "It doesn't look very good" for them, Fielding said.

About 500 tourists were visiting the prison compound at about 1:30 p.m. Sunday when a young, blond man drove up in a car with a surfboard strapped to the roof, a witness said. He carried a tennis bag.

He had been chatting with people calmly when he went into the cafe, pulled a high-powered rifle from his bag and started shooting.

One unidentified woman from Melbourne said she took refuge under a table when he opened fire.

"I just lay there, and all I could hear was the gun and screaming," she said.

Afterward, she said, "there were people just sitting there in their chairs where they'd been eating -- dead. . . . There was a weird sort of calm, as if no one could believe what they were seeing."

Wendy Scurr, an employee at the historic site, said the gunman left "shooting as he went, shooting everybody he could see."

He continued shooting outside the cafe, firing methodically at screaming tourists as they tried to flee.

"He wasn't going bang-bang-bang-bang -- it was bang' and then he'd pick someone else out and line them up and shoot them," witness Phillip Milburn told Australian radio.

The gunman next shot at two tour buses, killing several tourists in each and one of the drivers.

Witness Karen Jones said a little girl was killed. "The guy that we were with had to go and help take a stretcher in," she said, "and the mother was saying, You have to get my baby to the hospital, quick, quick.' But it was already dead." CAPTION: Medical workers rush a shooting victim from a helicopter in Hobart, Australia, about 30 miles northwest of Port Arthur massacre site.