There is an overnight train connecting Tbilisi, Georgia and Baku. Heading out of Azerbaijan, this costs 26AZN and departs nightly from Baku at 20:00. The time of the trip varies considerably based on how long is spent at the border (longer when entering Azerbaijan). This segment of track is currently being modernized as part of a project, financed in part by Azerbaijan, which includes the construction of a rail segment from Akhalkalaki, Georgia with Kars, Turkey. Originally scheduled to open in 2010, it is now planned to finish in 2012 connecting the railroads of Azerbaijan with Turkey via Georgia. Look out for Baku-Istanbul service once completed!
There is a domestic train line running from Astara on the Iranian border to Baku and there are high hopes to get a 300 km connector line built from Astara to Qazvin, Iran to connect the Azerbaijani and Iranian rail networks. Rail service to Iran, which once existed from Nakhchivan after crossing through southern Armenia, was severed after the border with Armenia was closed.