Both indices opened higher — Nifty at 23,897.65 and Sensex at 76,545.21 — before extending marginal gains in early trade