STOCKHOLM, Sweden (AP) _ Deputy Prime Minister Ingvar Carlsson, a longtime friend and political ally of assassinated Prime Minister Olof Palme, was nominated Saturday by the governing Social Democratic Party to succeed Palme.

The nomination virtually assures the 51-year-old Carlsson of the country's top government position. He must be approved by Sweden's parliament, the Riksdag, when it reconvenes this week, but the vote is considered a formality.

Carlsson has been deputy prime minister since Palme won his second term as prime minister in 1982. More recently, he also has taken on the posts of environment minister and minister for future planning.

Carlsson automatically took over as head of a caretaker government shortly after Palme was shot on a Stockholm street late Friday while walking with his wife, Lisbeth.

Palme's other Cabinet ministers, required by the constitution to resign upon the death of a prime minister, will stay on as caretakers pending Riksdag approval of a new head of government. No new election is required.

The Social Democrats hold only 159 of the Riksdag's 349 seats, but ususally are backed by the Communist Party, with 19 seats, on important votes. The three non-socialist opposition parties, which hold a total of 171 seats, will be consulted routinely by the Riksdag speaker before the vote on Carlsson's nomination, but are not expected to oppose it.

Carlsson headed emergency meetings of the caretaker government Saturday morning and then went to Drottningholm Castle to formally notify King Carl XVI Gustaf.

Foreign Minister Sten Andersson said the Social Democratic Party's executive body met for 90 minutes before unanimously nominating Carlsson to succeed Palme.

''Ingvar Carlsson knows the party well, has an ideologically strong basis in it and his ability to hold it together is great,'' Andersson said. ''In short he is the best chairman to find today and no other names were discussed.''

Andersson said the party executive's choice, backed by the powerful trade union confederations that form the party's backbone, will be formally sanctioned by a party vote Monday.

Upon approval from the Riksdag, Carlsson will become Sweden's fourth Social Democratic head of government since the party first came to power in the 1940s. Per Albin Hansson, Tage Erlander and Palme headed previous Social Democratic governments.

The blond, bespectacled Carlsson started his political career at about the same time as Palme and has been a member of his inner circle of advisers ever since Palme first became prime minister in 1969.

In addition to their political association, Carlsson and Palme have been close friends. They bought summer cottages next door to each other on the Baltic Gotland isle of Faaroe.

Carlsson was born into a worker's family in Boras in western Sweden on Nov. 9, 1934. While studying political science at Lund University, he became chairman of of the Socialist Students Union and won the attention of then- Prime Minister Tage Erlander.

Like Palme, he was given a post as a secretary in the Government House after graduation and became known as one of ''Tage's bright boys.''

He enrolled several years later in Northwestern University in Evanston, Ill., where he studied economics. On his return to Sweden, he became chairman of the Social Democratic Youth Association.

Carlsson initially developed a reputation as a radical ideologist, but became increasingly pragmatic over the years. He lacked Palme's fire and flamboyance, instead debating in a stolid, stonefaced manner.

He became Sweden's youngest-ever member of Parliament in 1965 when he was elected to a seat at age 31. Four years later, when Palme became prime minister, Carlsson was named minister of education, again becoming the youngest person ever to hold that post.

Carlsson was minister of housing and physical planning in 1973-76. During 1976-82, while a conservative coalition headed the government, Carlsson headed socialist planning for a political comeback.