William II of Bavaria (5 April 1365—31 May 1417) was duke of Bavaria-Straubing and count of Holland (listed as William VI), Hainaut (listed as William IV) and Zeeland. He ruled from 1404 until 1417, when he died from an infection caused by a dog bite.
William was a son of Albert I of Bavaria and Margaret of Brieg. William, allied with the Hooks, was in conflict with his father until 1394. In 1404 he succeeded him as count of Holland, Hainaut and Zeeland and duke of Bavaria-Straubing.
In 1408 in the Battle of Othée William, Duke John the Fearless of Burgundy, and Duke Louis VII of Bavaria defeated the citizens of Liège who had revolted against William's brother John, the bishop of Liège. As a result, he was no longer, as count of Hainaut, obliged to pay homage to the bishop. William's reign was marked by internal strife within the county of Holland. In particular, Lord John V of Arkel supported William's enemies in Holland. William conquered Arkel in 1412, at which point John accepted his defeat and Arkel was annexed by Holland.
William claimed Friesland as the count of Holland. Expeditions under previous counts had failed to conquer Friesland. Only Stavoren was captured in 1398. William II also sent expeditions to the region but Stavoren was regained by the Frisians in 1414. Prior to his death, William ensured his nobles swore allegiance to his only daughter, Jacqueline. Jacqueline was the only child by his wife, Margaret, a daughter of Philip the Bold whom he married in 1385, at the Burgundian double wedding in Cambrai, at the same time his sister, Margaret, married John the Fearless.
However, on William's death in 1417, a war of succession broke out between his brother John, the bishop of Liège, and his daughter, Jacqueline. This would be the last episode of the Hook and Cod wars and finally place Holland and Hainaut into Burgundian hands. The duchy of Bavaria-Straubing was divided between the dukes of Bavaria, the major portion went to Bavaria-Munich in 1429.