Brigham and Women’s Hospital and the union representing 3,300 of its nurses said they reached tentative agreement on a new contract, averting what would have been the largest nurses strike in state history. The compromise came early Sunday morning after 15 hours of negotiations, ending a long and bitter bargaining process between the Massachusetts Nurses Association and one of the city’s biggest teaching hospitals.