Prime Minister Margaret Thatcher tonight named veteran diplomat and political adviser Douglas Hurd, 54, to her Cabinet as the new minister for Northern Ireland, a post generally regarded as the toughest and most thankless in British politics.

Hurd, regarded as a moderate within Thatcher's Conservative Party government, replaces James Prior, 56, another moderate.

Prior had begun suggesting in May that he was ready to leave office after three years of seeking to cope with the violence and seemingly intractable political and religious divisions between the Roman Catholic minority and the Protestant majority in the six British-ruled counties of Northern Ireland.

Although Prior, who never wanted the job, failed to achieve any breakthrough in his efforts to set up a power-sharing assembly in Ulster, he is viewed by many officials and observers here and in the Republic of Ireland to the south as having helped reduce some of the tensions in Ulster and improved the climate for at least discussing possible settlements.

The Economist magazine in July described Prior, who will retain his seat in Parliament, as "the best Ulster secretary since the advent of direct rule of the province by Britain in 1972."

The fact that Prior's departure had been expected for several months created pressure on Thatcher to name someone soon so Prior would not be a lame duck for too long at a time when there was both renewed violence in the province and new initiatives to start a dialogue between the Catholic parties of Ireland and Ulster and between London and Dublin.

The Irish government was also known to have been concerned about the departure of Prior, who had earned the respect of politicians there by helping defuse the turmoil over hunger strikes by IRA prisoners in Ulster in June 1981 when he took over the post, and by his efforts since then to achieve slow, sustainable progress.

Whether Hurd's appointment signals an effort to name another high-powered official to carry on Prior's approach, or to pursue a different path, remains to be seen.

Within the British government there seems to be no optimism among officials that anything but the smallest steps toward cooperation within Ulster and with Ireland can be achieved.

Hurd has held high posts steadily since Thatcher took office in 1979, even though he is closely associated with former Conservative prime minister Edward Heath, whom Thatcher ousted as party leader, and the liberal wing of the Conservative Party. After a diplomatic career that took him to posts in Peking, Rome and Washington, Hurd was picked by Heath in 1968 to run his office and served as his political secretary until 1974.

Thatcher was said to have been impressed by Hurd's grasp of complex issues and appointed him as a minister of state in the Foreign Office from 1979 to 1983 and then shifted him to a minister's post in the Home Office.

The scholarly Hurd is also the author of a half-dozen thrillers, including one, published in 1975, that is set in Northern Ireland.