Charles Haughey, a controversial millionaire politician with a knack for survival in adverse circumstances, became prime minister of Ireland for the second time today with a surprisingly large parliamentary majority after last month's indecisve national election.

Haughey, 56, who was prime minister from December 1979 until last June, defeated incumbent Garret FitzGerald by a vote of 86 to 79 in the 166-seat Irish parliament in Dublin. Haughey won the support of a three-member party and two independents in addition to the 81 members of his Fianna Fail party.

A spokesman for Sinn Fein the Workers Party said after the vote that its three members of parliament supported Haughey because they believed a Fianna Fail government had a better chance of surviving than a minority government of FitzGerald's Fine Gael Party, with 63 members of parliament, supported by the Labor Party's 15 members. This left FitzGerald with the additional support of just one independent in yesterday's parliamentary vote for prime minister.

Haughey (pronounced HAW-hee) now must keep the support of the five Sinn Fein and independent members while trying to deal with pressing economic problems that include dangerously large government budget deficits and foreign debts, 20 percent inflation and 13 percent unemployment.

Haughey's return as prime minister is the latest of a series of political comebacks that have marked his career. An accountant who amassed a substantial fortune as a financier, he rose rapidly in politics and served in several senior ministerial positions during the 1960s.

He was dismissed as minister of finance by then prime minister Jack Lynch in 1970 after being acquitted of criminal charges that he conspired to import arms into Ireland for use by Irish nationalist paramilitary forces in neighboring British-ruled Northern Ireland.

Although questions about the gun-running scandal have continued, Haughey later returned as health minister and won a bitter leadership fight to become prime minister when Lynch retired in 1979.

Fianna Fail narrowly lost a national election last June that produced a Fine Gael-Labor coalition government headed by FitzGerald, which was defeated in parliament over proposed tax increases to reduce the budget deficit.

A combative but taciturn man, Haughey has proved much less popular personally than FitzGerald. Blamed by critics in his own party for Fianna Fail's failure to win last month's election outright, Haughey defeated a post-election challenge to his leadership before bargaining for the support of the parliamentary independents.

British and Irish officials do not expect substantial change in Irish policy toward Northern Ireland.

FitzGerald has been more conciliatory toward Northern Ireland's Protestant British loyalist majority, while Haughey has emphasized his belief that Northern Ireland can no longer remain a British province. Neil Blaney, the most outspoken Irish nationalist parliamentary independent and a onetime Cabinet colleague of Haughey before splitting from Fianna Fail, said he voted for Haughey today because he received "a more receptive hearing" from Haughey than FitzGerald.

Haughey has said he wants to take up President Reagan's invitation to FitzGerald to visit Washington for St. Patrick's Day.