After escaping a filibuster from members of his own party, Mr. Hagel, a former Republican senator from Nebraska, prevailed in a 58-to-41 vote — the smallest margin for a defense secretary since the position was created in 1947,