Senior officials from Britain and Ireland met here today for the first time under the terms of a new peace agreement for Northern Ireland, as opponents of the accord clashed with police in demonstrations that left dozens injured.

British Northern Ireland Secretary Tom King and Irish Foreign Minister Peter Barry held eight hours of closed-door talks under heavy guard in East Belfast at Stormont Castle, the headquarters of British rule here. A joint statement following the meeting said they discussed security cooperation and measures to improve relations between the local armed forces and the minority Catholic community.

The officials arrived this morning by helicopter, landing inside a ring of more than 1,000 members of the Royal Ulster Constabulary. At the end of the castle driveway this afternoon, rows of riot-equipped policemen, backed by armored Land Rovers, faced about 100 angry demonstrators across a fence of barbed wire that had been erected overnight.

The main protest of the day, however, was held about a mile away, outside Maryfield House where a permanent secretariat, formed of civil servants from both countries, has been set up to carry out the agreement.

At midday, thousands of workers, led by Unionist political leader Ian Paisley, left the nearby Belfast shipyard complex to march up a four-lane highway to the secretariat building. The Unionists, called that because they favor perpetual Northern Irish unity with Great Britain, are drawn from the Protestant majority here.

They have opposed the new agreement, which gives Ireland a consultative voice in ruling the province through the regular meetings inaugurated between Barry and King today, as the first step toward capitulation to the desire of Catholics, known as Nationalists or Republicans, for a reunited Ireland.

Although Paisley and other Unionist politicians had called for a "dignified" and nonviolent protest, a core of several hundred demonstrators quickly pushed against the fence around the secretariat building, tearing the gate off its hinges. Rocks and sticks were hurled from the crowd as a line of several hundred police holding plexiglass shields used wooden batons to repel the demonstrators.

Police officials later said 38 officers were injured, eight of them seriously. At least two local Unionist officials, one of them displaying a bloody shirt and stitches in his head, said they had been beaten by police.

Paisley and other Unionist leaders denounced the heavy police presence in Belfast. As a result of the new agreement, they said, the country was even less secure than before, since they charged that the need for extra police in the city had left the border area virtually undefended against terrorist infiltration from the south.

As if to bear out their words, the Irish Republican Army this afternoon staged a mortar attack against a rural police station in County Armagh, about a quarter mile from the Irish border, injuring four officers. It was the third such attack this week, part of a newly launched IRA offensive against police installations and government construction sites that has killed five members of the security forces and two civilians since the Anglo-Irish agreement was signed.

Today's violence in Belfast marked one of the few times that Unionists have clashed with police here.

The Royal Ulster Constabulary and the Ulster Defense Regiment, the provincial military force, are composed almost exclusively of Protestants, and are known to be highly partisan in the centuries-old sectarian battles here. Catholics, comprising about one-third of the Northern Irish population of 1.5 million, feel discriminated against not only by law enforcement, but also by the judicial system and employment practices in the province.

Having little faith in Northern Irish institutions, the Catholics are believed by the British and Irish governments increasingly to support the terrorist IRA in its efforts to drive Britain out of the province.

According to British Prime Minister Margaret Thatcher and her Irish counterpart Garret FitzGerald, the agreement they signed Nov. 16 is designed to dry up backing for the IRA by persuading the Catholics that their voice will be amplified through Irish representation in the talks and the new secretariat.

The Unionists, judging that a violent campaign against the agreement would find little support on "the mainland" of Britain, have adopted a strategy of constitutional opposition and civil disobedience.

Two weeks ago, Paisley and Peter Robinson, the deputy leader of his Democratic Unionist Party resigned their seats in the British Parliament. The 13 remaining Unionist members of Parliament are scheduled to do the same before the end of the year, forcing a by-election early next year.