Sen. Gary Hart (D-Colo.) won the Maine Democratic presidential caucuses tonight, dealing a serious and possibly fatal blow to Walter F. Mondale's prospects for winning the nomination.

At a Democratic Party dinner in Boston, Hart said he "may have brought a political juggernaut to its knees." He paid tribute to his Maine campaign workers, saying they had "fashioned another political miracle."

Mondale, facing possible losses in Vermont on Tuesday and in Wyoming on March 10, told reporters after the dinner, "We're going to lose some more. But before this is over, I'm confident I'm going to be out ahead and be nominated."

Hart expanded his margin steadily as the returns came in from the 414 community caucuses, adding to the momentum he gained from his upset victory over Mondale in last Tuesday's New Hampshire presidential primary.

Even with the all-out backing of the entire hierarchy of the Maine Democratic Party and outside help rushed into the state when the threat became clear, Mondale was unable to stem the Hart tide.

With all of Maine's cities and towns reporting, Hart had 8,549 votes; Mondale, 7,364; uncommitted, 602; former senator George McGovern (D-S.D.), 178; Jesse L. Jackson, 105; and Sen. John Glenn (D-Ohio), 52.

Hart had 50.7 percent of the 16,850 votes counted and Mondale had 43.7 percent.

Hart declined to claim absolute victory before the count ended. But he said he felt that "by running neck and neck" with Mondale, despite the "disparity of resources deployed in the campaign, . . . this is a substantial victory and breakthrough for us."

Hart said he is eager to "engage the voters in Vermont, Massachusetts and other upcoming states in the debate over how we move this country forward. I believe the voters in Maine, like the voters in New Hampshire last week, made it clear they want this race to focus on our future, and not our past."

Ron Briggs, 23, the former George Washington University student who headed the Hart campaign here, called the result "a massive defeat of Walter Mondale. He's put everything in this state and he had the support of everybody who counted. He outspent us 10 to 1, but it was our message that got through."

Mondale said he was "encouraged" by the results in Maine, claiming that he had come from behind since his defeat by Hart in New Hampshire and that his new strategy of attacking Hart's record seemed to be working.

"Four days ago, if we'd have had this caucus, I would have lost overwhelmingly," he said. "We were gaining every day."

Mondale aides expressed confidence that he will catch up with Hart in southern primaries and caucuses on March 13 and 17. One aide, Mike Ford, said the Maine results will have no effect in the South and added: "I don't think Sen. Hart is in a position to compete with us."

Mondale rolled up margins of 2 to 1 or so in blue-collar cities such as Lewiston and Biddeford, and in the state capital of Augusta, where the state employes' union bused members to the caucus site. And here in Portland, Mondale edged Hart by 150 votes out of 1,349.

But Hart was running strong in the more affluent bedroom communities around Portland and in the liberal seacoast towns. He also carried Bangor, the second-largest city, where he had strong local supporters.

Democratic Gov. Joseph E. Brennan, who said last week that he would "be stunned" if Mondale lost, attributed the result to the "independence" of Maine voters, adding, a bit paradoxically, "They were clearly affected by the judgment of New Hampshire voters."

Both Brennan and Democratic Sen. George J. Mitchell insisted that Mondale remained a viable candidate for the nomination. "Any time you lose, it's a setback," Mitchell said, "but there's a long way to go. It is much too early to write him off."

The fragility of Mondale's his position, at least in New England, was underlined by a poll to be published in Monday editions of The Boston Globe.

The survey of 611 Massachusetts voters taken from Wednesday through Saturday showed Hart with 41 percent; Mondale, 29; Glenn, 12; and McGovern and Jackson, 4 apiece. The Massachusetts primary will be held March 13.

Hart forces, meanwhile, reported significant gains in building up delegate rosters since the New Hampshire primary.

Hart campaign aide William Shore said 99 delegates are committed to Hart on the March 13 primary ballot in Florida, compared with 34 a week ago. There are 84 delegate slots to be filled in the Florida primary, so Hart has more than enough candidates there, Shore said.

"In Illinois," he added, "we had slates in 10 of 22 congressional districts. Now we have slates in 17 of them. Four of the new slates had been committed to former Florida governor Reubin Askew and three to" Sen. Alan Cranston (D-Calif.). Finally, Shore said, in Pennsylvania, "we picked up 30 new delegates in the last three days."

Until New Hampshire, Hart had run a shoestring campaign here, with $20,000 raised in the state and young Briggs in charge.

Arrayed against him were Brennan and his organization, Mitchell, former governor Kenneth B. Curtis and the Democratic leaders of the legislature.

But Hart dumped in money for heavy television advertising the last few days, and Mondale was forced to counter with last-minute ads of his own.

Caucus participants began filling up the Deering High School gymnasium in Portland long before the 1 p.m. starting time. Mondale supporters carefully packed the first section of bleachers as part of a plan to begin a wave of applause when their candidate arrived. On the walls were scores of printed Mondale signs, a smaller number of hand-lettered Hart posters and a few each for Jackson and McGovern.

Mondale's organization was apparent as Dorothy Wright filed through the doorway with five elderly Portland residents. "I'm bringing them here," she said.

Patricia Jeffrey and Diane Simmons stood in the gymnasium awaiting the start of the session and talked about why they had come to vote for Mondale.

"I believe he's very sincere and for the people," Jeffrey said.

"I think he has the experience," Simmons said. "We like the old ways, not necessarily the new ways."

But others indicated a growing receptiveness to Hart's appeal as a candidate promising a turn away from the kind of politics Mondale has practiced.

Kelly Cunningham, passing out Hart literature, said he was a relatively new convert to Hart's cause. "I see him as the most electable," he said.

Caucus participants in Portland spent more than three hours in the service of the Democratic process. After speeches by Mondale, Gov. Brennan and others, they broke up into smaller precinct meetings in school classrooms. There they continued the debate between Mondale and Hart over a nuclear freeze and the build-down concept, figured how best to get themselves to the state convention in May and mostly waited for the long process of registration.

In Room 209, Peter Weyl was balancing his daughter, Elizabeth, in a backpack and talking about Hart. He said he had decided to vote for Hart since New Hampshire. Before that he had planned to support Mondale, believing that a quick resolution in the Democratic nominating contest could help the party unite to defeat President Reagan.

The New Hampshire vote persuaded him that voters may want to move the party in another direction, however. "I'm willing to give Hart a chance," he said. "I could live with Mondale. But right now we have a chance to push the party in a slightly different direction."

Almost two hours later, he and his wife were two among 41 people in Room 209 to give Hart a one-vote victory over Mondale.

The Maine caucuses had been no more than an asterisk on the 1984 political calendar until Hart upset Mondale in New Hampshire.

Maine was a major political battleground last autumn, when the state convention straw vote became the showcase for Mondale, Cranston and Sen. Ernest F. Hollings (D-S.C.) to demonstrate their organizational skills and personal appeal.

Smarting from an unexpected defeat at Cranston's hands in the Wisconsin straw vote, Mondale invested almost $200,000 and scores of staff members in gaining 51 percent in the non-binding straw poll. Cranston finished second with 29 percent, Hollings had 11 percent and Glenn, who sent no help to his local supporters, had 6 percent.

Hart bypassed the straw poll, lacking the funds and the organization to compete then in Maine. But he began dropping into the state regularly thereafter, en route to or from New Hampshire, to encourage his youthful local supporters.