HANNIBAL, Mo. (AP) _ The seven-month festival celebrating the 150th anniversary of Mark Twain's birth may have given Hannibal a big boost as a tourist attraction, but it left the city's government in a shambles.

With the celebration in its final week, the Mississippi River community of 19,000 people is without a mayor and three of its 12 city councilmen, victims of a bitter squabble caused at least in part by the festival.

''The sesquicentennial celebration has done remarkably well under adverse conditions,'' former Mayor John Lyng, a member of the festival commission, said in a recent interview. ''Out of a budget that eventually reached $850,000, we are only about $20,000 to $25,000 short and we should make that up with collections, sales of inventory and pledges by the end of the month.''

Even before the event opened last spring, it ran into problems. A $1.5 million budget was proposed, but that was trimmed to just over $560,000 as citizens and corporate contributors had second thoughts.

Organizers had envisioned a long series of concerts by top groups, permanent additions to the historic downtown district and even an international balloon race.

Some of it worked, some of it didn't. An amphitheater was built on the southern edge of the town's waterfront, but a theme stage planned for the northern part didn't materialize. The balloon race also failed to come off and some of the musical events were canceled.

Meantime, Lyng was defeated soundly as he sought re-election. Most attribute the loss to anti-festival sentiment.

However, Lyng's successor, Richard Cerretti, resigned Nov. 12 after being threatened with impeachment. Three councilmen accused him of misusing city equipment and labor and illegally taping telephone conversations.

The three councilmen, Wayne Pafford, John Hamilton and James Dexheimer, also resigned. All four men said they would seek re-election for their offices in a special election in February.

Twain would have loved it.

''When politics enter into municipal government,'' he once wrote, ''nothing resulting therefrom in the way of crimes and infamies is then incredible. It actually enables us to accept and believe the impossible.''

Twain - Samuel L. Clemens - was born on Nov. 30, 1835 in nearby Florida, Mo., but grew up in Hannibal, which was the setting for ''Adventures of Tom Sawyer'' and ''Adventures of Huckleberry Finn,'' whose publication 100 years ago was recalled on some souvenir T-shirts.

Cerretti had made the festival an issue in his mayoral campaign, saying there were better ways to spend city funds for economic development.

''I wasn't critical of the festival itself,'' Cerretti said Wednesday. ''I was critical of the planners. We spent huge sums of money and got nothing for it.

''We got monthly financial statements, but they were not accurate or complete. They still aren't. My personal feeling is that they're trying to hide something. Or maybe they don't have a bookkeeper, I don't know.

''In any case, the festival failed in its objective to fill our hotels and restaurants with paying customers.''

Although none of the impeachment charges against Cerretti involved the festival, his criticism of the festival had provoked resentment within the council.

The council voted last month to suspend the mayor with pay pending an impeachment hearing, which was canceled after the resignations were announced.

''Basically, I think the sesquicentennial was the first point of disagreement between the mayor and the council,'' said Lyng. ''It wasn't the biggest, but it was the first.''

Local feelings were not soothed, either, by an article in the Aug. 6 Wall Street Journal, which city officials said ''did a hatchet job'' on the town and the festival by listing all of its negative aspects.

''The reporter found and quoted lots of critics of the sesquicentennial, but apparently wasn't as zealous in his pursuit of the other side of the story,'' wrote Gil Stuenkel, managing editor of the Hannibal Courier-Post.

Through it all, however, the festival drew several hundred thousand visitors over the summer and nearly paid for itself.

''We'll know after Nov. 30,'' the official closing, said the Rev. Peter C. Hauser, who quit the sesquicentennial commission in the spring because ''there were waves threatening to sink the ship.'' He's changed his mind, however.

''I believe a sizeable portion of the community now recognizes that it was a worthwhile event,'' Hauser said. ''They didn't think it could be pulled off, but it was.''

''Maybe some of the dreams were too large,'' said Tom Boland, president of the Chamber of Commerce. ''I wish it had been even bigger, but there's just so much you can do in Hannibal.''

Lyng added: ''It's just too bad that the political laundry was hung out to dry just as we were calling national attention to ourselves.''