Abstract. We present a new algorithm that can output the rankdecomposition of width at most k of a graph if such exists. For that we use an algorithm that, for an input matroid represented over a fixed finite field, outputs its branch-decomposition of width at most k if such exists. This algorithm works also for partitioned matroids. Both these algorithms are fixed-parameter tractable, that is, they run in time O(n3 ) for each fixed value of k where n is the number of vertices / elements of the input. (The previous best algorithm for construction of a branchdecomposition or a rank-decomposition of optimal width due to Oum and Seymour [Testing branch-width. J. Combin. Theory Ser. B, 97(3) (2007) 385–393] is not fixed-parameter tractable.)