A flotilla of small boats, banging out the marine equivalent of the Anvil Chorus, made a last-ditch effort today to herd a 45-ton humpback whale out of a dead-end river slough and back to the open sea.

The whale stubbornly refused to cooperate.

Driven by the rhythmic clang of mallets on water-filled metal pipe, the massive black creature thrashed and circled for more than an hour in Shag Slough near the piling of a low bridge that is his gateway to freedom. As the whale grew increasingly agitated, his would-be rescuers were forced to retreat to protect their fragile fishing boats.

The whale, known locally as Humphrey although the national media prefers to call him E.T., has been swimming doleful circles in Shag Slough for more than five days, to the delight of sightseers and the utter befuddlement of federal and state biologists.

"Nobody has ever had a whale in a slough before," said state Sen. John Garamendi, who was at the scene all day to look after the interests of his newest constituent.

Why the whale came upriver remains a mystery.

San Francisco Chronicle columnist Herb Caen has suggested that the whale was on his way to Sacramento to protest Gov. George Deukmejian's environmental policy. Others speculate, with only slightly more credence, that the whale was attracted by low-frequency signals from nearby military transmission towers.

According to marine specialists, Humphrey apparently took a bad header in the Pacific on the way to his Mexican breeding ground more than two weeks ago. The creature swam into the San Francisco Bay, up the Sacramento River and eventually into an 18-foot-deep slough about 12 miles north of this Sacramento Delta town.

From here, he can go no farther. A land bridge seals the end of the slough, and the only way out is under the Liberty Island Bridge, a route that the whale has been, for five days, unable or unwilling to retrace.

Officials tried luring the animal out to sea with humpback mating sounds and frightening him with killer whale tapes. The efforts succeeded only in driving the whale farther back into the lacy network of sloughs -- swampy bogs -- and canals that make up the Sacramento Delta.

Disappointed scientists said they were considering removing some of the bridge piling and making another stab at pipe-banging, a technique called Oikomi used by the Japanese to chase dolphins away from tuna nets.

"The bridge seems to be a perceived barrier by the whale," said Sheridan Stone of the National Marine Fisheries Service. The danger in a prolonged stay is the river's low salinity: Humphrey needs salt water to cleanse his eyes and to provide his preferred seafood diet.

While the scientists ponder how to spring him, the whale is the biggest event in decades for Rio Vista, where the bait shops outnumber stop lights, and the local supermarket stocks rods and reels one aisle over from frozen foods.

"This is definitely bigger than the bass derby," said a customer at the Happy Lady Bait Shop, which was doing a brisk business in directions to Shag Slough at $1 a map.

Until police officials closed the area for today's rescue attempt, the levee along Shag Slough had been jammed with whale-watchers since Humphrey took up residence last Friday.