The U.S. and Saudi Arabia are nearing a historic pact that would offer the kingdom security guarantees and lay out a possible pathway to diplomatic ties with Israel if its government brings the war in the Gaza Strip to an end, people familiar with the matter said.