WASHINGTON — After one of the nation’s most protracted cabinet-level confirmation delays, the Senate Thursday approved Loretta E. Lynch to be attorney general. She is the first African-American woman to hold the position.

Ms. Lynch, the United States attorney for the Eastern District of New York, was confirmed 56 to 43, with 10 Republicans voting for her.

Her confirmation took longer than that for all but two other nominees for the office: Edwin Meese III, who was nominated by President Ronald Reagan, and A. Mitchell Palmer, who was picked by President Woodrow Wilson, according to the Congressional Research Service.

Republicans have found themselves in a quandary for months. They longed to replace Attorney General Eric H. Holder Jr., and they agreed that Ms. Lynch was qualified for the job. But they opposed her because Ms. Lynch defended President Obama’s executive actions on immigration.