Massayoshi Ohira was reelected prime minister of Japan today at a special session of the parliament, ending a week of bitter party factionalism that had threatened to replace him with his chief rival Takeo Fukuda.

Fukuda, who also has served as premier, was the choice of a splinter group in the ruling Liberal Democratic Party that blamed Ohira for calling elections last month. Instead of gaining, 12 seats and the parliamentary majority Ohira had predicted, the party lost one seat and now holds only 248 seats in the 511-member lower house of the Japanese Diet or parliament.

Ohira had refused to heed the calls for his regisnation.

Ohira, 69, won 138 or 511 voters cast, against Fukuda's 121. There were 252 blank votes. The showdown came after Ohira and Fukuda failed to win a majority of 256 votes in the first roll call vote.

The dispute presented the Liberal Democrats with their severest test since the party was formed 24 years ago.

Fukuda, who spearheaded the opposition, was backed by two other influential leaders, former prime minister Takeo Milki, and Yasuhiro Nakasone, former head of the defense agency.

Ohira was supported by followers of former prime minister Kakuei Tanaka, who quit the party after he was arrested in connection with a payoff scandal in 1974. However, Tanaka still retains strong influence in the party as an independent member of the lower house.