Two Northern Irish policemen on foot patrol were killed and a third was seriously wounded early this morning in a bomb and rifle attack by the Irish Republican Army in the town of Armagh. The attack occurred one minute after midnight, timed, an IRA communique said, "for the New Year."

Thus, even before the celebratory New Year's church bells had stopped ringing in Armagh, 35 miles southwest of Belfast, the violence of 1985 was promised for 1986 in Northern Ireland. In the last year, 23 policemen were killed and 363 injured in IRA attacks, the highest annual total in nearly a decade.

The attack was one of the more visible difficulties that have greeted the new Anglo-Irish agreement signed in November by Prime Minister Margaret Thatcher and her counterpart in the Republic of Ireland, Garret FitzGerald, designed to show the people of Northern Ireland that there is a better way to resolve their longstanding differences.

In some ways, the killings are the easiest problem to deal with since bombs and bullets can be matched in kind. An additional 550 British troops are scheduled to be added to the more than 8,000 already in the province, historically known as Ulster, on Thursday.

But to effect a permanent peace, the agreement seeks to reconcile the two long-irreconcilable communities that breed and nurture the violence. While the plan is still too new to judge, the signs so far are not encouraging.

The extremes claiming to represent the two sides of the Northern Ireland divide -- majority Protestants and minority Catholics -- have vowed that this attempt at an imposed peace, like all others in the past, will fail. In the six weeks since its signing, they have made strenuous efforts to see that it does.

The IRA killings are part of a broader campaign to undercut British attempts to pacify both communities -- the Protestants by lowering the level of violence inflicted by the IRA, and the Catholics by diminishing their sense that Northern Ireland is a land under foreign military occupation. Most Protestants favor continued union with Britain while many Catholics support the IRA's battle to unite Northern Ireland with the republic to the south.

Under the new agreement, both Britain and Ireland want to restructure the overwhelmingly Protestant Royal Ulster Constabulary, making it into a more nonpartisan police force that can take over security duties now aided by British Army troops. In addition to direct attacks at constabulary targets, the IRA has sought to disrupt a major British construction program to build new police stations and repair those damaged in previous terrorist attacks.

IRA threats against construction companies and their employes working on the program have been successful. In recent weeks, the building has come to a virtual standstill. Where the work has continued, it has been undertaken by the very British Army troops it was designed to make less visible.

A perhaps more ominous sign of trouble to come is the hunger strike by two Catholic prisoners who are members of the Irish National Liberation Army, an IRA splinter group, that began in the past two weeks at Northern Ireland's Maze Prison. Deaths during previous hunger strikes, most recently in 1980 and 1981, led to widespread rioting and violence, and the political rise of Sinn Fein, the IRA's legal political party.

Sinn Fein's increasing electoral success, at the expense of the leading moderate Catholic party, the Social Democratic and Labor Party, in local elections over the past year, helped persuade Thatcher that the new agreement was necessary. By giving Dublin a formal consultative voice in running the province, she and FitzGerald hoped to reassure Catholic nationalists dreaming of a reunited Ireland that their minority grievances could be addressed short of that goal.

For the IRA and Sinn Fein, however, nothing less than an end to British rule in the province is acceptable.

But to Protestant Unionists, who favor continued union with Great Britain, the participation of Dublin is an unacceptable breach of sovereignty and a direct threat to their identity.

It is the militant Unionists who have posed the most immediate threat to the accord. With a roar that drowns out even the sounds of the IRA bombs, Unionist leader Ian Paisley ends his near-daily speeches to cheering protest crowds in the province with a trademark crescendo of defiance: "Never. Never. Neverrrr."

In the conference rooms and quiet offices of the British and Irish governments, Paisley is wistfully thought of as a kind of Northern Irish Bull Connor. Just as the old segregationist order was about to collapse on the white Alabama police commissioner even as he battled daily to keep blacks out of white schools, they hope Paisley's efforts ultimately will prove futile.

But as Paisley often points out, he has fought and won similar battles before, playing no small part in bringing down two previous British governments that tried to end the troubles in Northern Ireland, in 1970 and 1974.

The next three weeks will mark a crucial test of the efforts of Paisley and his fellow Unionist political leader, James Molyneaux, to prove to Thatcher that Northern Irish Protestants will not accept the accord. On Jan. 23, a special parliamentary election will be held that they believe will demonstrate their point overwhelmingly.

Having failed to force Thatcher to hold a referendum in Northern Ireland on the agreement, Paisley, Molyneaux and 13 other Unionist politicians last month resigned the seats they held in the British Parliament. The Jan. 23 special by-election vote, they say, will serve as the plebiscite Thatcher would not allow, and their overwhelming reelection will be a vote of Protestant outrage.

Northern Ireland has 17 seats in Parliament. Aside from the 15 that were held by the resigning Unionists, one belongs to the Social Democratic and Labor Party, and the other to Sinn Fein.

Sinn Fein is not likely to contest the seats. For the SDLP, which strongly supports the Anglo-Irish agreement, however, the election could be as crucial a test as for the Unionists. At least four of the 15 seats are in districts with large Catholic populations, and were won last time by slim Unionist majorities. If the Social Democratic and Labor Party can win any of them, it will be a major victory for the party, and for the agreement. If the Unionists win them all, however, Paisley will claim a democratic victory for his stand against the accord.

Paisley and Molyneaux already are well into the campaign. Yesterday, just hours before the IRA attack in Armagh, they launched a protest march of Unionists who plan to walk the 75 miles from Londonderry to Belfast. On arrival there Saturday, they will hold the latest in a series of mass Protestant demonstrations.

Should the election results fail to convince Thatcher of Unionist ire, they plan an extended campaign of civil disobedience, making the province "ungovernable" through the refusal of its majority to pay taxes or work at civil service jobs.