Mohit Ulva smashed a boundary off the final ball as India chased down Pakistan's 338-run target after slipping to 252 for eight.