The United States remains determined to secure the withdrawal of all foreign forces from Lebanon despite recent setbacks to the process, President Reagan said yesterday.

Reagan used a reception for the visiting emir of Bahrain to deliver a message he will be repeating to Lebanese President Amin Gemayel later this week.

Reagan and the emir agreed that Lebanon should be freed of occupation by all foreign forces and that the United States and Bahrain should work together for a peaceful political settlement in Lebanon and in the Middle East as a whole.

The emir, Sheik Isa bin Salman Khalifa, endorsed American diplomatic efforts to reach a Lebanese solution but differed from Reagan on the future of the Palestinians in the Israeli-occupied West Bank and Gaza Strip.

The Bahraini leader spoke of the legitimate right of the Palestinian people to live in peace "within secure national boundaries," while Reagan talked of a solution based on justice, security and the principles of resolutions passed by the U.N. Security Council.

At a welcoming ceremony on the White House lawn, the diminutive emir, dressed in gold-fringed robes and traditional headdress, told his host, "We are prepared to do our best and participate in sincere international efforts to establish security in the Middle East region within this framework, to put an end to this terrible conflict and enable the people of the region to live in peace."

But aside from diplomatic niceties, the Bahraini leader offered little in terms of practical suggestions for resolving the Lebanese impasse, the result of the continued presence in Lebanon of Syrian and Israeli troops and forces of the Palestine Liberation Organization.

Gemayel, who arrived in Washington yesterday, is to meet with Secretary of State George P. Shultz on Thursday and with Reagan on Friday.

Their talks are expected to focus on ways to persuade Syria to cooperate in the withdrawal of foreign forces from neighboring Lebanon.