Former heavyweight champion Muhammad Ali landed the surprise knockout punch that transformed Sen. Orrin G. Hatch, R-Utah, from the prime opponent of a landmark fair housing bill to a co-sponsor of the legislation passed 11 days ago by the Senate.

And Ali weighed in because Sen. Edward M. Kennedy, D-Mass., asked him to.Until Friday, even Hatch's spokesman hadn't known about Ali's lobbying effort.

"It was Muhammad Ali that really turned that bill around (for me)," Hatch said yesterday through his spokesman, Paul Smith. "He contacted me, on Kennedy's behalf and contacted Kennedy on my views. We compromised and passed a good bill, all because of Ali," Smith quoted Hatch as saying.

Ali said that Kennedy, aware of Ali's increasing involvement in politics, called about a week before the scheduled vote and asked him to talk to Hatch, who in 1980 led the filibuster that defeated similar fair housing legislation.

"Senator Kennedy told me that they had been trying to get that bill through for nine years, and that if he (Hatch) opposed it, it would never have been carried," Ali said Friday.

After researching the costs of the bill and its effect on fair housing, Ali said he talked with Hatch on July 31, and that the next day Hatch said he would back the bill. It was passed on Aug. 2 by a vote of 94 to 3.

"I told him that this was an opportunity to show that he was interested in more that just the conservatives, that he served all the people," Ali said.

Jeff Smith, a spokesman for Kennedy, said he was not aware of Ali's lobbying, but noted that "in the end, he (Hatch) was an enthusiastic cosponsor of the bill."

Paul Smith, Hatch's spokesman, said that Ali and Hatch, himself a veteran of 12 professional boxing matches, have talked frequently on the telephone in recent months, becoming good friends. And next week, Ali will attend the Republican National Convention as the guest of Hatch, Sen. Arlen Specter, R-Pa., and Sen. John W. Warner, R-Va.

Ali, who also counts among his political allies Virginia senatorial candidate Charles S. Robb and Virginia Lt. Gov. Douglas Wilder, both Democrats, said he will campaign for Vice President Bush, Robb and Hatch this fall.

"I know that people will come to see me because they consider me a legendary figure" and not because of his political leanings, Ali said. "But it that's what it takes to get the people out, I'll be there," he said.