The Vatican confirmed today that two of four Nicaraguan priests holding government posts had been presented with an ultimaturm to leave those positions within two weeks or be suspended from priestly duties.

The ultimatum, after several years of tension between the priests and the Roman Catholic hierarchy, was revealed by Nicaraguan Foreign Minister Miguel D'Escoto, a Maryknoll priest. A Nicarguan newspaper quoted him yesterday as saying he had received a letter from the Vatican last Wednesday informing him that he had two weeks to choose between his governmental and priestly duties.

A Vatican spokesman, Msgr. Giulio Nicolini, said today the ultimatum also referred to the Rev. Ernesto Cardenal, a diocesan priest who is minister of culture.

According to church sources, two other priests in high posts have also been told by Nicaraguan church officials that they have only a short period left in which to make their decision. Last month, the Rev. Fernando Cardenal, the minister of education and Ernesto's brother, was expelled from the Jesuit order.

The priests have said repeatedly that whatever the punishment they will remain in their government posts. The Rev. Edgar Parrales, Nicaragua's ambassador to the Organization of American States in Washington, said last week that he had asked for permission to leave the priesthood in June 1983 but had never received a reply.

The priests would not be defrocked but forbidden from exercising their priestly duties. Those duties would be restored in the event that they decided in the future to renounce their government posts, according to church officials, but until then they would be forbidden to identify themselves as priests or to be addressed as "father."