Autonomous navigation of agricultural robot is an essential task in precision agriculture, and success of this task critically depends on accurate detection of crop rows using computer vision methodologies. This is a challenging task due to substantial natural variations in crop row images due to various factors, including, missing crops in parts of a row, high and irregular weed growth between rows, different crop growth stages, different inter-crop spacing, variation in weather condition, and lighting. The processing time of the detection algorithm also needs to be small so that the desired number of image frames from continuous video can be processed in real-time. To cope with all the above mentioned requirements, we propose a crop row detection algorithm consisting of the following three linked stages: (1) color based segmentation for differentiating crop and weed from background, (2) differentiating crop and weed pixels using clustering algorithm and (3) robust line fitting to detect crop rows. We test the proposed algorithm over a wide variety of scenarios and compare its performance against four different types of existing strategies for crop row detection. Experimental results show that the proposed algorithm perform better than the competing algorithms with reasonable accuracy. We also perform additional experiment to test the robustness of the proposed algorithm over different values of the tuning parameters and over different clustering methods, such as, KMeans, MeanShift, Agglomerative, and HDBSCAN.