Last year, Rep. Phillip Burton (D-Calif.) was the toast of the Democratic Party because of his imaginative gerrymandering of California's congressional districts, giving his party the chance to gain five seats in the Nov. 2 elections.

This year, the flamboyant and powerful Burton, who lost the House majority leader's job by just one vote in 1974 and has been courted by lobbyists for causes ranging from labor to the environment, faces the prospect of losing the House seat he's held for 18 years.

His opponent, Republican state Sen. Milton Marks, has released a poll taken in July that shows him leading Burton by 43 to 36 percent. Marks also has earlier polls showing that Burton has high negative ratings because he allegedly has an abrasive personality and takes more interest in personal power than in his district.

Every chance he gets, Marks notes that, despite the nearly 3-to-1 Democratic registration advantage in the district, 20 percent of the Democrats who voted in the June primary declined to mark their ballots for Burton, who was unopposed.

Burton's staff discounts Marks' poll data as out of date, although Burton's campaign coordinator, Michael Novelli, acknowledges that this year we "have a race," unlike Burton's last two campaigns, which he won by nearly 70 percent.

If Burton, 56, is the king of the congressional lobbies, Marks, 62, is the prince of this city's streets, and Novelli acknowledges that he is an "indefatigable campaigner."

Marks has represented a good slice of San Francisco in the legislature, with a brief interlude as a municipal court judge, since 1958, despite the fact that the Republicans are a distinct minority in the city.

His vote-getting ability is legendary. He appears at weddings, bar mitzvahs and wakes with astonishing frequency. There's an old San Francisco joke: if you advertise to sell your car, Marks would send you a note hoping you get a good price.

In his redistricting plan, which was passed by the Democratic-controlled legislature, Burton appears to have gotten overconfident about his reelection prospects. He fortified the new district of his brother, Rep. John L. Burton (D-Calif.), by exchanging some black and labor strongholds in his old district for some less solid Democratic neighborhoods such as Marks' middle-income Richmond district, which had been in John Burton's.

At the time, Phillip Burton made no effort to contain his delight at how his brother's new district "curls in and out like a snake." He reveled in the outrage of old Republican adversaries like Reps. Robert K. Dornan and John H. Rousselot, whose districts he chopped to pieces.

Yet Burton's joy was short lived. His brother soon decided that the pressures of politics were too much, and announced his retirement. Marks, so popular in San Francisco that he won a 1980 Democratic primary with a labor-backed write-in campaign, took a close look at the weakened district Phillip Burton had left for himself, and filed to run against him.

Driving to a speech at City College of San Francisco, where he would appeal strongly for student volunteer help, Burton admitted that he had "somewhat" of an image problem.

"I've never been a tub-thumper for myself," he said.

Novelli tries to view Marks' threat as a blessing.

"Phil is obviously someone who gets people's blood boiling. They either like him or they don't," he said. But this year the broad range of Democratic factions in San Francisco have offered "almost unanimous support for Phillip, and enthusiastic support." All realize what Burton's loss would mean to their ability to influence events in Washington, Novelli contends.

Marks is a liberal Republican, voting like Burton on civil rights, welfare and gay-rights issues. Like Burton, he supports an immediate nuclear freeze and opposes the right-to-life amendment.

But in a fund-raising letter to conservative political action groups, he emphasized only Burton's unabashed liberalism.

Burton spends most of his time ignoring Marks' record, and instead lambasts President Reagan for his economic policies as overlooking "the needy and powerless of our land." This prompts Marks to complain that "Phil has some kind of idea that he is running against Ronald Reagan."

Was Burton surprised when his brother quit after he had worked so hard to try to ensure his reelection?

"Surprise may be not quite the right word, but it had that flavor," he said. "I accepted it. I love him. I want him to do what he wants to do."