President Carter yesterday scored a morale-boosting victory over Sen. Kennedy in a straw poll at an Iowa fund-raising dinner, but Kennedy won the more politically important endorsement of the Cook County Democratic Party in Chicago.

The Cook County endorsement, prompted by Mayor Jane Byrne's endorsement of Kennedy last week, was made by voice vote after a wrenching two-hour debate in which Rep. Daniel Rostenkowski (D-Ill.) and other local party leaders argued unsuccessfully that it was premature, unfair to Carter and not necessarily representative of the feelings of Cook County voters.

The endorsement should deliver to Kennedy most of the 49 national convention delegates running inside the city in the March 18 primary, although at least one powerful committeeman, Park District Superintendent Edmund Kelly of the northwest side, said he would have to poll his precinct captains before deciding what to do.

Robert Torricelli, Carter's Illinois campaign chairman, noted the divisions evident in the debate and said the Carter campaign will now "go to the streets." Torricelli said Carter would campaign in Chicago neighborhoods before a fund-raising dinner in suburban Rosemont on Dec. 6.

The Carter campaign will run candidates pledged to the president in all Illinois congressional districts, including Chicago, Torricelli said. Illinois elects 152 delegates in congressional districts, and another 27 at large at a state party convention.

The endorsement by the 80-member organization of ward and township committeemen gives Byrne, who did not attend the meeting, a vote of confidence as she prepares to leave for Boston tonight to join Kennedy for his formal announcement tomorrow. Byrne will accompany Kennedy to New Hampshire and Maine before returning here with the senator for campaign appearances Wednesday night and Thursday.

Rostenkowski, head of the Illinois Democratic congressional delegation, argued that the endorsement was not on the agenda given committeemen. "I say we are acting prematurely because we haven't had a chance to have a discussion," he said.

Alderman Roman Pucinski, a former congressmen, said "the president of the United States deserves better than the shabby treatment he's getting here" and argued it was unfair to make an endorsement before all candidates had a chance to make their case.

Pucinski also said the party may not reflect voter feelings because a straw poll he took in his north side ward showed opinion divided on Kennedy and Carter.

While the Byrne endorsement may have helped Kennedy nationally, it also may have had an adverse effect in downstate Illinois, where Byrne is growing unpopular. "There has been a little backlash downstate from Mayor Byrne's endorsement," said Todd Renfrow, a Springfield businessman who is chairman of the Democratic County Chairmen's Association. "Don't count Carter out yet."

Carter's win in Iowa, by almost 3 to 1, demonstrated the president's organizational strength in the state, the first to spawn a draft-Kennedy group this year.

But unlike four years ago when a straw poll victory at the same Jefferson-Jackson Day dinner propelled Carter, then a little-known former governor, from obscurity, this win was expected.

Kennedy forces, realizing they would be soundly defeated, did not contest the vote, although the senator's sister-in-law Ethel Kennedy and her oldest son Joseph made a last-minute trip to the$30 a-plate-dinner in Ames, Iowa.

Their fears were well-founded. Among the 2,224 Democrats polled by the Iowa Daily Press Association, 70.63 percent favored Carter as the party's 1980 presidential nominee.Kennedy was second with 26.01 percent. California Gov. Edmund G. (Jerry) Brown Jr. was third with less than 1 percent.

The straw ballot results were released the same day the Carter campaign received two other encouraging pieces of information.

First, a Time magazine poll showed the huge lead Kennedy held over Carter has dropped from 33 percentage points to 10 points since the Massachusetts senator indicated he would be a candidate for the Democratic nomination.

Then, Carter, who has had uneasy relations with some black groups, received the endorsement of Coretta Scott King, widow of slain civil rights leader Martin Luther King Jr.

In the Time poll, Kennedy topped Carter by 49 to 39 percent among the 752 Democrats and independents surveyed by the polling firm of Yankelovich, Skelly and White Inc. Twelve percent were undecided. Carter trailed Kennedy 58 percent to 25 percent in a similar poll in August.

Jody Powell, Carter's press secretary, said the Time poll and the Iowa straw ballot proved what the White has been saying all along: that Carter's popularity would increase when he had a genuine opponent.

Kennedy, however, was credited with a 54 to 20 percent lead over Carter in a CBS-New York Times poll released last night. On the Republican side, the poll said Ronald Reagan led with 37 percent, followed by John B. Connally with 15 percent and Tennessee Sen. Howard H. Baker Jr. with 13 percent.

The draft-Kennedy group in Iowa, which plans to go out of business Saturday three days after Kennedy formally announces his candidacy, openly admitted defeat yesterday.

Matt Wanning, head of the draft-Kennedy group formed in March, said he thought the 3-to-1 vote was "fair indication of the organizational strength" of the Carter and draft-Kennedy forces.

"it was an organizational test and they beat us," said Wanning. "It shows how far we have to go in a short amount of time."

William Rumjue, Carter's Iowa coordinator, was buoyed by the victory. "We've tested our organization and we feel good about it," he said. "This gives us confidence."

Rumjue, however, was cautious in looking ahead to Iowa's precinct caucuses in January, the first formal test of the 1980 presidential race.

"I clearly think it's winnable for us," he said. "But it's going to be a real horse race."

With a full-time paid staff of more that 20 persons, Rumjue has been organizing for months around the dinner. The campaign chartered 13 buses to bring Carter supporters from around the state.

Both camps recorded strong union support, Unions representing machinists and auto workers brought large blocs of tickets so their members could cast votes for Kennedy; groups representing teachers, communication workers and seafarers bought blocs of tickets for Carter.

In another political development yesterday, former Wisconsin governor Patrick J. Lucey, who recently resigned as Carter's ambassador to Mexico, announced he will serve as deputy manager of Kennedy's campaign. Lucey, a longtime associate of the Kennedy family, said he will concentrate on trying to recruit governors and big city mayors to the kennedy camp.