RIO DE JANEIRO — Venus Williams will leave the Rio Olympics with a medal after all.

Williams is guaranteed to tie the Olympic tennis record with her fifth medal after she and teammate Rajeev Ram rallied to win their mixed doubles semifinal on Saturday.

advertisement | advertise on newsday

Williams owns three women’s doubles golds with sister Serena and a singles championship from 2000. But she was upset in the first round in both draws in Rio de Janeiro.

Initially not expected to enter mixed doubles, Williams wound up teaming with Ram. On Saturday, they beat India’s Sania Mirza and Rohan Bopanna 2-6, 6-2, 10-3 tiebreak.

Williams couldn’t stop jumping up and down afterward.

Kathleen McKane won five medals — one gold — in the 1920s.